Added FormatFlag.UserEscaped.
authorMarcos Henrich <marcos.henrich@xamarin.com>
Fri, 11 Jul 2014 11:30:53 +0000 (12:30 +0100)
committerMarcos Henrich <marcos.henrich@xamarin.com>
Fri, 11 Jul 2014 11:30:53 +0000 (12:30 +0100)
mcs/class/System/System/Uri.cs
mcs/class/System/System/UriHelper.cs

index b4d899880d0fd37d93ab0c3b98fd0998be160aca..46a7ee88d11a5a9ebd9ac645afb74216c786d6a4 100644 (file)
@@ -1462,6 +1462,9 @@ namespace System {
                        if (UriHelper.HasCharactersToNormalize (uriString))
                                formatFlags |= UriHelper.FormatFlags.HasUriCharactersToNormalize;
 
+                       if (userEscaped)
+                               formatFlags |= UriHelper.FormatFlags.UserEscaped;
+
                        // from here we're practically working on uriString.Substring(startpos,endpos-startpos)
                        int startpos = pos + 1;
                        int endpos = uriString.Length;
index b0c546eaa47e014af1ab676971cdb45ff16b7f33..1ff3dea06c66a5088fbeb32c34da77e1d40030be 100644 (file)
@@ -18,6 +18,7 @@ namespace System {
                        HasUriCharactersToNormalize = 1 << 1,
                        HasHost = 1 << 2,
                        HasFragmentPercentage = 1 << 3,
+                       UserEscaped = 1 << 4,
                }
 
                [Flags]
@@ -241,8 +242,9 @@ namespace System {
                private static string FormatChar (char c, bool isEscaped, UriSchemes scheme, UriKind uriKind,
                        UriComponents component, UriFormat uriFormat, FormatFlags formatFlags)
                {
-                       if (!isEscaped && NeedToEscape (c, scheme, component, uriKind, uriFormat, formatFlags) ||
-                               isEscaped && !NeedToUnescape (c, scheme, component, uriKind, uriFormat, formatFlags))
+                       var userEscaped = (formatFlags & FormatFlags.UserEscaped) != 0;
+                       if (!isEscaped && !userEscaped && NeedToEscape (c, scheme, component, uriKind, uriFormat, formatFlags) ||
+                               isEscaped && (userEscaped || !NeedToUnescape (c, scheme, component, uriKind, uriFormat, formatFlags)))
                                return HexEscapeMultiByte (c);
 
                        if (c == '\\' && component == UriComponents.Path) {