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

Should % in DocumentUri.Path be encoded in DocumentUri.ToUri()? #1005

Open
shenglol opened this issue Aug 18, 2023 · 0 comments
Open

Should % in DocumentUri.Path be encoded in DocumentUri.ToUri()? #1005

shenglol opened this issue Aug 18, 2023 · 0 comments

Comments

@shenglol
Copy link

shenglol commented Aug 18, 2023

DocumentUri.ToUri() produces identical Uris for different file paths:

var filePath1 = @"c:/foo bar/test#.txt";
var filePath2 = @"c:/foo%20bar/test%23.txt";

DocumentUri documentUri1 = DocumentUri.FromFileSystemPath(filePath1);
DocumentUri documentUri2 = DocumentUri.FromFileSystemPath(filePath2);

Console.WriteLine(documentUri1.Path); // /c:/foo bar/test#.txt
Console.WriteLine(documentUri2.Path); // /c:/foo%20bar/test%23.txt

var uri1 = documentUri1.ToUri();
var uri2 = documentUri2.ToUri();

Console.WriteLine(uri1); // file:///c:/foo bar/test%23.txt
Console.WriteLine(uri2); // file:///c:/foo bar/test%23.txt

Can anyone confirm if this is by design or a bug? If it's a bug, I think the fix would be to encode % in DocumentUri.Path before assigning it to UriBuilder.Path in DocumentUri.ToUri().

@shenglol shenglol changed the title Should DocumentUri.Path be encoded in DocumentUri.ToUri()? Should % in DocumentUri.Path be encoded in DocumentUri.ToUri()? Aug 18, 2023
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