Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaesar Chen <schen381@users.noreply.github.com>2017-05-05 03:15:24 +0300
committerGitHub <noreply@github.com>2017-05-05 03:15:24 +0300
commitdebabf13447248ef7cf70cf4e098ceb55e626163 (patch)
treeb5837a1ce4f45c99dae77f13fdb9cf59e86fcd4d /src/System.Web.HttpUtility
parentb1af73da70b59ae8e6967e50fbad6b2936bda009 (diff)
parentb66139c3192025fcc47e48e62e639d841fcbb9b1 (diff)
Merge pull request #18301 from schen381/bugfix_17627
Change UrlDecode behavior and merge test cases for .Net core and desktop
Diffstat (limited to 'src/System.Web.HttpUtility')
-rw-r--r--src/System.Web.HttpUtility/src/System/Web/Util/HttpEncoder.cs47
-rw-r--r--src/System.Web.HttpUtility/tests/HttpUtility/HttpUtilityTest.cs18
2 files changed, 10 insertions, 55 deletions
diff --git a/src/System.Web.HttpUtility/src/System/Web/Util/HttpEncoder.cs b/src/System.Web.HttpUtility/src/System/Web/Util/HttpEncoder.cs
index 7f3235c01a..8458b6b51f 100644
--- a/src/System.Web.HttpUtility/src/System/Web/Util/HttpEncoder.cs
+++ b/src/System.Web.HttpUtility/src/System/Web/Util/HttpEncoder.cs
@@ -283,45 +283,14 @@ namespace System.Web.Util
}
else if (b == '%' && i < count - 2)
{
- if (bytes[pos + 1] == 'u' && i < count - 5)
- {
- int h1 = HttpEncoderUtility.HexToInt((char)bytes[pos + 2]);
- int h2 = HttpEncoderUtility.HexToInt((char)bytes[pos + 3]);
- int h3 = HttpEncoderUtility.HexToInt((char)bytes[pos + 4]);
- int h4 = HttpEncoderUtility.HexToInt((char)bytes[pos + 5]);
-
- if (h1 >= 0 && h2 >= 0 && h3 >= 0 && h4 >= 0)
- {
- // valid 4 hex chars
- char ch = (char)((h1 << 12) | (h2 << 8) | (h3 << 4) | h4);
- i += 5;
-
- byte[] chBytes = Encoding.UTF8.GetBytes(new[] { ch });
- if (chBytes.Length == 1)
- {
- b = chBytes[0];
- }
- else
- {
- for (int j = 0; j < chBytes.Length - 1; j++)
- {
- decodedBytes[decodedBytesCount++] = chBytes[j];
- }
- b = chBytes[chBytes.Length - 1];
- }
- }
- }
- else
- {
- int h1 = HttpEncoderUtility.HexToInt((char)bytes[pos + 1]);
- int h2 = HttpEncoderUtility.HexToInt((char)bytes[pos + 2]);
-
- if (h1 >= 0 && h2 >= 0)
- {
- // valid 2 hex chars
- b = (byte)((h1 << 4) | h2);
- i += 2;
- }
+ int h1 = HttpEncoderUtility.HexToInt((char)bytes[pos + 1]);
+ int h2 = HttpEncoderUtility.HexToInt((char)bytes[pos + 2]);
+
+ if (h1 >= 0 && h2 >= 0)
+ {
+ // valid 2 hex chars
+ b = (byte)((h1 << 4) | h2);
+ i += 2;
}
}
diff --git a/src/System.Web.HttpUtility/tests/HttpUtility/HttpUtilityTest.cs b/src/System.Web.HttpUtility/tests/HttpUtility/HttpUtilityTest.cs
index df32d63fdd..357f526408 100644
--- a/src/System.Web.HttpUtility/tests/HttpUtility/HttpUtilityTest.cs
+++ b/src/System.Web.HttpUtility/tests/HttpUtility/HttpUtilityTest.cs
@@ -439,16 +439,10 @@ namespace System.Web.Tests
new object[] {"http://127.0.0.1:8080/app%%Dir/page.aspx?foo=b%%r", "http://127.0.0.1:8080/app%%Dir/page.aspx?foo=b%%r"},
new object[] {"http://127.0.0.1:8080/appDir/page.aspx?foo=ba%r", "http://127.0.0.1:8080/appDir/page.aspx?foo=b%61%r"},
new object[] {"http://127.0.0.1:8080/appDir/page.aspx?foo=b%uu0061r", "http://127.0.0.1:8080/appDir/page.aspx?foo=b%uu0061r"},
+ new object[] {"http://127.0.0.1:8080/appDir/page.aspx?foo=b%u0061r", "http://127.0.0.1:8080/appDir/page.aspx?foo=b%u0061r"},
+ new object[] {"http://127.0.0.1:8080/appDir/page.aspx?foo=b%%u0061r", "http://127.0.0.1:8080/appDir/page.aspx?foo=b%%u0061r"},
};
- public static IEnumerable<object[]> UrlDecodeDataToBytes_netcoreapp =>
- new[]
- {
- new object[] {"http://127.0.0.1:8080/appDir/page.aspx?foo=bar", "http://127.0.0.1:8080/appDir/page.aspx?foo=b%u0061r"},
- new object[] {"http://127.0.0.1:8080/appDir/page.aspx?foo=b%ar", "http://127.0.0.1:8080/appDir/page.aspx?foo=b%%u0061r"},
- };
-
-
[Theory]
[MemberData(nameof(UrlDecodeData))]
public void UrlDecode(string decoded, string encoded)
@@ -457,14 +451,6 @@ namespace System.Web.Tests
}
[Theory]
- [MemberData(nameof(UrlDecodeDataToBytes_netcoreapp))]
- [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "dotnet/corefx #17627")]
- public void UrlDecodeToBytes_Netcoreapp(string decoded, string encoded)
- {
- Assert.Equal(decoded, Encoding.UTF8.GetString(HttpUtility.UrlDecodeToBytes(encoded, Encoding.UTF8)));
- }
-
- [Theory]
[MemberData(nameof(UrlDecodeDataToBytes))]
public void UrlDecodeToBytes(string decoded, string encoded)
{