diff options
Diffstat (limited to 'mcs/class/System.Web.Routing')
-rw-r--r-- | mcs/class/System.Web.Routing/System.Web.Routing/Route.cs | 16 | ||||
-rw-r--r-- | mcs/class/System.Web.Routing/Test/System.Web.Routing/RouteTest.cs | 19 |
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 () |