Uri: fix path component of merged uris with parent directory references above the...
authorRolf Bjarne Kvinge <RKvinge@novell.com>
Mon, 30 Aug 2010 23:16:51 +0000 (01:16 +0200)
committerRolf Bjarne Kvinge <RKvinge@novell.com>
Mon, 30 Aug 2010 23:55:47 +0000 (01:55 +0200)
mcs/class/System/System/Uri.cs
mcs/class/System/Test/System/UriTest.cs

index f94788cfd00c95ce6da8bd54684fa1a476c71d46..d950223ff29382a65528f675a127d82a4fdb40d2 100644 (file)
@@ -392,6 +392,10 @@ namespace System {
                                                path = path.Remove (pos + 1, path.Length - pos - 1);
                        }
                        
+                       // 6 g)
+                       while (path.StartsWith ("/../"))
+                               path = path.Substring (3);
+                       
                        if (!userEscaped)
                                path = EscapeString (path);
                }               
index 00baf03212d4dfaf15ce76961621f88598c83562..2e70ffed4fbfcd50f9d8ea7951575a02223134c2 100644 (file)
@@ -156,6 +156,7 @@ namespace MonoTests.System
                        uri = new Uri (new Uri("http://www.contoso.com/xxx/yyy/index.htm"), "../../../foo/bar/Hello World.htm?x=0:8", false);
 #if NET_2_0
                        Assert.AreEqual ("http://www.contoso.com/foo/bar/Hello%20World.htm?x=0:8", uri.AbsoluteUri, "#rel9");
+                       Assert.AreEqual ("/foo/bar/Hello%20World.htm", uri.AbsolutePath, "#rel9-path");
 #else
                        Assert.AreEqual ("http://www.contoso.com/../foo/bar/Hello%20World.htm?x=0:8", uri.AbsoluteUri, "#rel9");
 #endif