Skip to content

[Uri] HttpUtility.UrlDecode will decode twice compare to WebUtility.UrlDecode #29142

@Eilon

Description

@Eilon

From @daohunliwei on Saturday, 30 March 2019 06:35:43

Describe the bug

The framework I am using is net core 2.0.
I have a string that has been urlencode twice.When I use 「System.Web.HttpUtility.UrlDecode」 to decode, I only call it once, but all the strings are decoded.
When this method is running on Windows, everything works fine. When running on Linux, the above problem occurs.
Later, I changed 「System.Net.WebUtility.UrlDecode」to decode, and the results on both sides are the same.

To Reproduce

Steps to reproduce the behavior:

  1. Using this version of ASP.NET Core '2.2.105'
  2. Run this code
string url="https%3a%2f%2foapi.dingtalk.com%2fservice%2fget_corp_token%3fsignature%3dFHOywukz2tdfFpx2dPg5medckUMauhAFOuppnDx%252b2NQ%253d"
var right = System.Net.WebUtility.UrlDecode(url);
//resultRight=https://oapi.dingtalk.com/service/get_corp_token?signature=FHOywukz2tdfFpx2dPg5medckUMauhAFOuppnDx%2b2NQ%3d
var wrong = System.Web.HttpUtility.UrlDecode(url);
//resultWrong=https://oapi.dingtalk.com/service/get_corp_token?signature=FHOywukz2tdfFpx2dPg5medckUMauhAFOuppnDx+2NQ=

Expected behavior

I want to call decode only once to decode one layer.

Screenshots

none.

Additional context

Add any other context about the problem here.
Include the output of dotnet --info

.NET Core SDK (reflecting any global.json):
Version: 2.2.104
Commit: 73f036d4ac
Runtime Environment:
OS Name: centos
OS Version: 7
OS Platform: Linux
RID: centos.7-x64
Base Path: /usr/share/dotnet/sdk/2.2.104/
Host (useful for support):
Version: 2.2.2
Commit: a4fd7b2c84
.NET Core SDKs installed:
2.2.104 [/usr/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Copied from original issue: dotnet/aspnetcore#8938

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions