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

System.Uri .AbsoluteUri duplicates paths #1031

Closed
TylerLeonhardt opened this issue Dec 18, 2019 · 3 comments
Closed

System.Uri .AbsoluteUri duplicates paths #1031

TylerLeonhardt opened this issue Dec 18, 2019 · 3 comments
Milestone

Comments

@TylerLeonhardt
Copy link

TylerLeonhardt commented Dec 18, 2019

Pass in a file path with ASCII characters into the Uri constructor and get the AbsoluteUri:

> new Uri("/Users/tyleonha/Code/PowerShell/Misc/foo.ps1").AbsoluteUri
file:///Users/tyleonha/Code/PowerShell/Misc/foo.ps1

Everything looks great. Now pass in a path with non-ASCII characters:

> new Uri("/Users/tyleonha/Code/PowerShell/Misc/测试.ps1").AbsoluteUri
file:///Users/tyleonha/Code/PowerShell/Misc/%E6%B5%8B%E8%AF%95.ps1/Users/tyleonha/Code/PowerShell/Misc/%E6%B5%8B%E8%AF%95.ps1

The file is url encoded correctly but the file path is duplicated.

Same happens if I pass in the path a Uri string:

new Uri("file:///Users/tyleonha/Code/PowerShell/Misc/%E6%B5%8B%E8%AF%95.ps1").AbsoluteUri
file:///Users/tyleonha/Code/PowerShell/Misc/%E6%B5%8B%E8%AF%95.ps1/Users/tyleonha/Code/PowerShell/Misc/%E6%B5%8B%E8%AF%95.ps1

If I add a drive letter, this no longer repros:

> new Uri("C:/Users/tyleonha/Code/PowerShell/Misc/测试.ps1").AbsoluteUri
file:///C:/Users/tyleonha/Code/PowerShell/Misc/%E6%B5%8B%E8%AF%95.ps1

We know that the path passed in is absolute... so I'm a bit confused as to why this duplication is happening.

I'm running this on macOS Mojave with .NET Core 3.1 (via PowerShell).

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Net untriaged New issue has not been triaged by the area owner labels Dec 18, 2019
@TylerLeonhardt
Copy link
Author

Related possibly... the ToString() method shows similar (but worse) behavior:

> new Uri("/Users/tyleonha/Code/PowerShell/Misc/测试.ps1").ToString()
file:///Users/tyleonha/Code/PowerShell/Misc/%E6%B5%8B%E8%AF%95.ps1/Users/tyleonha/Code/PowerShell/Misc/测试.ps1

Some of the characters are decoded, some are left as is...

@TylerLeonhardt
Copy link
Author

I went as deep as I could with the AbsoluteUri codepath but got to this method (ran with reflection) still gave me the same results... so it's deeper but what this is method is doing is over my head, I'm afraid.

@MihaZupan
Copy link
Member

Duplicate of #1061

@MihaZupan MihaZupan marked this as a duplicate of #1061 Dec 19, 2019
@karelz karelz added this to the 5.0.0 milestone Aug 18, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 11, 2020
@karelz karelz removed the untriaged New issue has not been triaged by the area owner label Oct 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants