Skip to content

Double-escape of URI strings #10

@andybochmann

Description

@andybochmann

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions