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

Double-escape of URI strings #10

Open
andybochmann opened this issue Jun 16, 2022 · 0 comments
Open

Double-escape of URI strings #10

andybochmann opened this issue Jun 16, 2022 · 0 comments

Comments

@andybochmann
Copy link

Looking at line 117 of SitemapService.cs, the service is calling Uri.EscapeUriString() to escape the AbsoluteUri. However, that doesn't seem necessary, because the AbsoluteUri property on a Uri is escaped already.

Escaping it again will break the URLs because the % will be escaped as %25.

var loc = new XElement(xmlns + "loc", Uri.EscapeUriString(node.Url.AbsoluteUri));

For example:

var original = "http://example.com/test-®-test";
Console.WriteLine(original); 
// http://example.com/test-®-test

var uri = new Uri(original, UriKind.Absolute);
Console.WriteLine(uri.AbsoluteUri);
// http://example.com/test-%C2%AE-test

var escaped = Uri.EscapeUriString(uri.AbsoluteUri);
Console.WriteLine(escaped);
// http://example.com/test-%25C2%25AE-test
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

No branches or pull requests

1 participant