Open ificator opened 1 year ago
This PR fixes https://github.com/aspnet/AspNetKatana/issues/393.
Currently ToUriComponent will skip encoding the % when it looks like it's part of percent-encoded character:
ToUriComponent
%
var ps = new PathString("/test%20name.txt"); Console.WriteLine("{0}", ps.ToUriComponent()); // Output: /test%20name.txt
However, ToUriComponent should output a correctly encoded version of the decoded path represented by the PathString:
PathString
var ps = new PathString("/test%20name.txt"); Console.WriteLine("{0}", ps.ToUriComponent()); // Output: /test%2520name.txt
Said another way, the FromUriComponent and ToUriComponent methods should be symmetrical:
FromUriComponent
string input = "/test%2520name.txt"; var ps = PathString.FromUriComponent(input); string output = ps.ToUriComponent(); Console.WriteLine("{0}", input == output); // Expect this to output 'true'
The fix is to remove the check for percent encoding.
This PR fixes https://github.com/aspnet/AspNetKatana/issues/393.
Currently
ToUriComponent
will skip encoding the%
when it looks like it's part of percent-encoded character:However,
ToUriComponent
should output a correctly encoded version of the decoded path represented by thePathString
:Said another way, the
FromUriComponent
andToUriComponent
methods should be symmetrical:The fix is to remove the check for percent encoding.