Invalid escapes are left untouched on .NET 4.0 and higher.
authorMarcos Henrich <marcos.henrich@xamarin.com>
Thu, 24 Jul 2014 11:34:11 +0000 (12:34 +0100)
committerMarcos Henrich <marcos.henrich@xamarin.com>
Thu, 24 Jul 2014 11:34:11 +0000 (12:34 +0100)
mcs/class/System/System/UriHelper.cs

index a320df3e39dc45ad72154fcb28159f56c69486fa..640388ba8e8c82035d82911979fc3be0f180028c 100644 (file)
@@ -229,7 +229,16 @@ namespace System {
                                if (c == '%') {
                                        int iStart = i;
                                        char surrogate;
-                                       char x = Uri.HexUnescapeMultiByte (str, ref i, out surrogate);
+                                       bool invalidUnescape;
+                                       char x = Uri.HexUnescapeMultiByte (str, ref i, out surrogate, out invalidUnescape);
+
+#if NET_4_0
+                                       if (invalidUnescape) {
+                                               s.Append (c);
+                                               i = iStart;
+                                               continue;
+                                       }
+#endif
 
                                        string cStr = str.Substring(iStart, i-iStart);
                                        s.Append (FormatChar (x, surrogate, cStr, scheme, uriKind, component, uriFormat, formatFlags));