[Mono-bugs] [Bug 651966] New: System.Web.Routing regex constraints differ semantically from .NET

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Nov 7 23:53:48 EST 2010


https://bugzilla.novell.com/show_bug.cgi?id=651966

https://bugzilla.novell.com/show_bug.cgi?id=651966#c0


           Summary: System.Web.Routing regex constraints differ
                    semantically from .NET
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.6.x
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.Web
        AssignedTo: mhabersack at novell.com
        ReportedBy: bassam at symform.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12)
Gecko/20101026 Firefox/3.6.12 ( .NET CLR 3.5.30729; .NET4.0E)

System.Web.Routing seem to differ when processing route constraints form .NET.
It looks like .NET treats the regex constraints as a full pattern, i.e.
beginning in '^' and ending in '$', while mono's implementation does partial
matches. Below is a small repro.

Reproducible: Always

Steps to Reproduce:
using System;
using System.Collections.Specialized;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace MonoRoutingBug
{
    class Program
    {
        static void Main(string[] args)
        {
            Route r = new Route("Foo/{id}", new RouteValueDictionary(new {
controller = "Foo", action = "Retrieve" }), new RouteValueDictionary(new { id =
@"\d{1,10}" }), new MvcRouteHandler()); 
            RouteData data = r.GetRouteData(new DummyHttpContext("/Foo/x123"));
            // Expected : null to be returned (.NET FX returns null)
            // Actual: Mono return data with { controller = "Foo", action =
"Index", id = "x123" }
        }
    }

    class DummyRouteHandler : IRouteHandler
    {
        public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            return null;
        }
    }

    class DummyHttpRequest: HttpRequestBase
    {
        private Uri url;

        public DummyHttpRequest(string urlString)
        {
            url = new Uri(new Uri("http://localhost"), urlString);
        }

        public override string AppRelativeCurrentExecutionFilePath { get {
return "~" + url.LocalPath; } }
        public override string PathInfo { get { return string.Empty; } }
        public override string HttpMethod{ get { return "~" + url.LocalPath; }
}
        public override NameValueCollection QueryString { get { return
HttpUtility.ParseQueryString(url.Query); } }
    }

    class DummyHttpContext : HttpContextBase
    {
        private DummyHttpRequest req;

        public DummyHttpContext(string urlString)
        {
            req = new DummyHttpRequest(urlString);
        }

        public override HttpRequestBase Request { get { return req; } }
    }
}

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list