Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Habersack <grendel@twistedcode.net>2011-01-22 14:42:10 +0300
committerMarek Habersack <grendel@twistedcode.net>2011-01-22 14:43:14 +0300
commitd66b7f5543156bb47567a016bb3df4307a5fd75b (patch)
treefcd12d33cf4d94e7e9113aecb232c34c87dde593 /mcs/class/System.Web.Routing
parent144632ec7c3bdb6e39d0cf472e5d919903cb1b9d (diff)
[asp.net,routing] Fix for bug #651966. Regular expression constraints must be treated as absolute regexps.
Diffstat (limited to 'mcs/class/System.Web.Routing')
-rw-r--r--mcs/class/System.Web.Routing/System.Web.Routing/Route.cs16
-rw-r--r--mcs/class/System.Web.Routing/Test/System.Web.Routing/RouteTest.cs19
2 files changed, 34 insertions, 1 deletions
diff --git a/mcs/class/System.Web.Routing/System.Web.Routing/Route.cs b/mcs/class/System.Web.Routing/System.Web.Routing/Route.cs
index cd255453ec1..e817e0a1543 100644
--- a/mcs/class/System.Web.Routing/System.Web.Routing/Route.cs
+++ b/mcs/class/System.Web.Routing/System.Web.Routing/Route.cs
@@ -150,8 +150,22 @@ namespace System.Web.Routing
string s = constraint as string;
if (s != null) {
string v = values [parameterName] as string;
- if (!String.IsNullOrEmpty (v))
+ if (!String.IsNullOrEmpty (v)) {
+ int slen = s.Length;
+ if (slen > 0) {
+ // Bug #651966 - regexp constraints must be treated
+ // as absolute expressions
+ if (s [0] != '^') {
+ s = "^" + s;
+ slen++;
+ }
+
+ if (s [slen - 1] != '$')
+ s += "$";
+ }
+
return Regex.Match (v, s).Success;
+ }
return false;
}
diff --git a/mcs/class/System.Web.Routing/Test/System.Web.Routing/RouteTest.cs b/mcs/class/System.Web.Routing/Test/System.Web.Routing/RouteTest.cs
index 3f704f1fc6f..ded39b115f8 100644
--- a/mcs/class/System.Web.Routing/Test/System.Web.Routing/RouteTest.cs
+++ b/mcs/class/System.Web.Routing/Test/System.Web.Routing/RouteTest.cs
@@ -960,6 +960,25 @@ namespace MonoTests.System.Web.Routing
Assert.IsNull (rd, "#2");
}
+ [Test (Description="Bug #651966")]
+ public void GetRouteData47 ()
+ {
+ var r = new Route ("Foo/{id}", new StopRoutingHandler ()) {
+ Defaults = new RouteValueDictionary (new {
+ controller = "Foo",
+ action = "Retrieve"
+ }),
+ Constraints = new RouteValueDictionary (new {
+ id = @"\d{1,10}"
+ })
+ };
+
+ var hc = new HttpContextStub ("/Foo/x123", String.Empty);
+ var rd = r.GetRouteData (hc);
+
+ Assert.IsNull (rd, "#1");
+ }
+
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void GetVirtualPathNullContext ()