diff options
author | Duncan Mak <duncan@mono-cvs.ximian.com> | 2003-08-13 04:24:08 +0400 |
---|---|---|
committer | Duncan Mak <duncan@mono-cvs.ximian.com> | 2003-08-13 04:24:08 +0400 |
commit | deb01b640e22a7f81feae6b9c3be316d34081d75 (patch) | |
tree | d292d8064d9d42164aaa1db21c2024206dd87861 /mcs/class/System/System | |
parent | cbf8ff8c293f15ae72d5b7b155695334527aa8ee (diff) |
(constructor): Properly implement RFC 2396, Par. 5.2,
part 6a.
This fixes bug #45614.
svn path=/trunk/mcs/; revision=17304
Diffstat (limited to 'mcs/class/System/System')
-rw-r--r-- | mcs/class/System/System/ChangeLog | 14 | ||||
-rwxr-xr-x | mcs/class/System/System/Uri.cs | 15 |
2 files changed, 22 insertions, 7 deletions
diff --git a/mcs/class/System/System/ChangeLog b/mcs/class/System/System/ChangeLog index ac27b88169d..ccc75314568 100644 --- a/mcs/class/System/System/ChangeLog +++ b/mcs/class/System/System/ChangeLog @@ -1,3 +1,17 @@ +2003-08-12 Duncan Mak <duncan@ximian.com> + + * Uri.cs (constructor): Properly implement RFC 2396, Par. 5.2, + part 6a, which says: + + In other words, any characters after the last (right-most) + slash character, if any, are excluded. + + Previously, when merging "a://foo.com/foo" with "bar", we yield + the result "a://foo.com/foobar", instead of the correct + "a://foo.com/bar". + + This fixes bug #45614. + 2003-07-27 Andreas Nahr <ClassDevelopment@A-SoftTech.com> * SRDescriptionAttribute.cs: Moved from System.Diagnostics directory diff --git a/mcs/class/System/System/Uri.cs b/mcs/class/System/System/Uri.cs index 060808eebe7..033529d86de 100755 --- a/mcs/class/System/System/Uri.cs +++ b/mcs/class/System/System/Uri.cs @@ -114,10 +114,12 @@ namespace System this.fragment = baseUri.fragment; return; } - + int pos = relativeUri.IndexOf (':'); if (pos != -1) { + int pos2 = relativeUri.IndexOfAny (new char [] {'/', '\\'}); + if (pos2 > pos) { // equivalent to new Uri (relativeUri, dontEscape) Parse (relativeUri); @@ -132,7 +134,7 @@ namespace System return; } } - + // 8 fragment pos = relativeUri.IndexOf ('#'); if (pos != -1) { @@ -151,7 +153,7 @@ namespace System relativeUri = relativeUri.Substring (0, pos); } - if (relativeUri[0] == '/') { + if (relativeUri [0] == '/') { path = relativeUri; if (!userEscaped) path = EscapeString (path); @@ -161,12 +163,12 @@ namespace System // par 5.2 step 6 a) path = baseUri.path; pos = path.LastIndexOf ('/'); - if (pos > 0) + if (pos >= 0) path = path.Substring (0, pos + 1); - + // 6 b) path += relativeUri; - + // 6 c) int startIndex = 0; while (true) { @@ -211,7 +213,6 @@ namespace System // 6 f) if (path.Length > 3 && path.EndsWith ("/..")) { pos = path.LastIndexOf ('/', path.Length - 4); - Console.WriteLine ("6f " + pos); if (pos != -1) if (path.Substring (pos + 1, path.Length - pos - 4) != "..") path = path.Remove (pos + 1, path.Length - pos - 1); |