2009-04-21 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Tue, 21 Apr 2009 11:54:56 +0000 (11:54 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Tue, 21 Apr 2009 11:54:56 +0000 (11:54 -0000)
* Uri.cs: Fix some issues found with Moonlight (see new unit
tests)

svn path=/trunk/mcs/; revision=132239

mcs/class/System/System/ChangeLog
mcs/class/System/System/Uri.cs

index 66703480405aa656d917fd0385d2196ae917da15..89464ce511d9de31ae1ca6d65899d83ba6630a59 100644 (file)
@@ -1,3 +1,8 @@
+2009-04-21  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * Uri.cs: Fix some issues found with Moonlight (see new unit
+       tests)
+
 2009-04-14  Sebastien Pouliot  <sebastien@ximian.com>
 
        * Uri.cs: Fix processing of %2f and %5c in paths. Avoid a few
index d807c02605db2df047e6b0f491f0abdb8fdaffbe..f26c4bee9252544c78cee27584be97c4d875bd42 100644 (file)
@@ -112,10 +112,15 @@ namespace System {
 
                // Constructors         
 
+#if NET_2_1
+               public Uri (string uriString) : this (uriString, UriKind.Absolute) 
+               {
+               }
+#else
                public Uri (string uriString) : this (uriString, false) 
                {
                }
-
+#endif
                protected Uri (SerializationInfo serializationInfo, 
                               StreamingContext streamingContext) :
                        this (serializationInfo.GetString ("AbsoluteUri"), true)
@@ -190,8 +195,8 @@ namespace System {
                }
 
                public Uri (Uri baseUri, Uri relativeUri)
-                       : this (baseUri, relativeUri.OriginalString, false)
                {
+                       Merge (baseUri, relativeUri == null ? String.Empty : relativeUri.OriginalString);
                        // FIXME: this should call UriParser.Resolve
                }
 
@@ -219,8 +224,8 @@ namespace System {
 #endif
 
                public Uri (Uri baseUri, string relativeUri) 
-                       : this (baseUri, relativeUri, false) 
                {
+                       Merge (baseUri, relativeUri);
                        // FIXME: this should call UriParser.Resolve
                }
 
@@ -229,9 +234,17 @@ namespace System {
 #endif
                public Uri (Uri baseUri, string relativeUri, bool dontEscape) 
                {
+                       userEscaped = dontEscape;
+                       Merge (baseUri, relativeUri);
+               }
+
+               private void Merge (Uri baseUri, string relativeUri)
+               {
 #if NET_2_0
                        if (baseUri == null)
                                throw new ArgumentNullException ("baseUri");
+                       if (!baseUri.IsAbsoluteUri)
+                               throw new ArgumentOutOfRangeException ("baseUri");
                        if (relativeUri == null)
                                relativeUri = String.Empty;
 #else
@@ -240,8 +253,6 @@ namespace System {
 #endif
                        // See RFC 2396 Par 5.2 and Appendix C
 
-                       userEscaped = dontEscape;
-
                        // Check Windows UNC (for // it is scheme/host separator)
                        if (relativeUri.Length >= 2 && relativeUri [0] == '\\' && relativeUri [1] == '\\') {
                                source = relativeUri;
@@ -1362,8 +1373,12 @@ namespace System {
                                // It must be Unix file path or Windows UNC
                                if (uriString [0] == '/' && Path.DirectorySeparatorChar == '/'){
                                        ParseAsUnixAbsoluteFilePath (uriString);
+#if NET_2_1
+                                       isAbsoluteUri = false;
+#else
                                        if (kind == UriKind.Relative)
                                                isAbsoluteUri = false;
+#endif
                                        
                                } else if (uriString.Length >= 2 && uriString [0] == '\\' && uriString [1] == '\\')
                                        ParseAsWindowsUNC (uriString);