Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure 'FromUriComponent' and 'ToUriComponent' are symmetric #506

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ificator
Copy link

This PR fixes #393.

Currently ToUriComponent will skip encoding the % when it looks like it's part of percent-encoded character:

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:

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:

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.

@Tratcher
Copy link
Member

FYI this project is only receiving critical security fixes. Behavioral breaking changes are unlikely to be accepted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

With 4.x release behavior of decoding url parameters (path and query parameters) has changed.
3 participants