Bug 658 - UriTemplate.Match fails for wildcard template
Summary: UriTemplate.Match fails for wildcard template
Alias: None
Product: Class Libraries
Classification: Mono
Component: WCF assemblies ()
Version: 2.10.x
Hardware: PC Linux
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2011-09-06 20:32 UTC by Roman Sakno
Modified: 2012-02-19 12:09 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Roman Sakno 2011-09-06 20:32:25 UTC
The following code throws theArgumentOutOfRangeException exception:
var template = new UriTemplate("*");
            var matchResult = template.Match(new Uri(""), new Uri(""));

Stack trace:
at System.String.CompareOrdinal(System.String strA, Int32 indexA, System.String strB, Int32 indexB, Int32 length)
at System.UriTemplate.Match(System.Uri baseAddress, System.Uri candidate)

This problem is actual for 2.10.5 version only.

As a result, WCF REST programming model is not working.
Comment 1 Yury Chetyrko 2012-02-04 08:13:43 UTC
Problem still exists in 2.10.8.

The problem is the following code:

if (!wild && (cp.Length - c) != (tEnd - i) ||
  String.CompareOrdinal (cp, c, template, i, tEnd - i) != 0)
    return null; // suffix doesn't match

I'm not sure but seems it should be like this:

if (!wild && ((cp.Length - c) != (tEnd - i) ||
  String.CompareOrdinal (cp, c, template, i, tEnd - i) != 0))
    return null; // suffix doesn't match
Comment 2 Yury Chetyrko 2012-02-04 08:15:51 UTC
mono-2.10.8\mcs\class\System.ServiceModel.Web\System\UriTemplate.cs:line 306
Comment 3 Gonzalo Paniagua Javier 2012-02-19 12:09:48 UTC
Fixed in master/bd0c4311b3