Skip to content

.GetLeftPart does unicode character encoding under the hood #11253

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

Open
erdembayar opened this issue Apr 28, 2025 · 3 comments
Open

.GetLeftPart does unicode character encoding under the hood #11253

erdembayar opened this issue Apr 28, 2025 · 3 comments
Labels
area-System.Net untriaged New issue has not been triaged by the area owner

Comments

@erdembayar
Copy link

erdembayar commented Apr 28, 2025

Hi
We learned that the .GetLeftPart method performs Unicode character encoding under the hood. This caused a subtle bug that went undetected for months. It should be called in https://learn.microsoft.com/en-us/dotnet/api/system.uri.getleftpart?view=net-9.0
Initially we used this method to remove SAS token later discovered it does more than removing SAS token.
We confirmed this manually and then decompiled the code to verify it.

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Apr 28, 2025
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Apr 28, 2025
@erdembayar erdembayar changed the title .GetLeftPart does unicode encoding under the hood .GetLeftPart does unicode character encoding under the hood Apr 28, 2025
@gewarren gewarren added area-System.Net and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Apr 28, 2025
Copy link
Contributor

Tagging subscribers to this area: @dotnet/ncl

@liveans
Copy link
Member

liveans commented Apr 28, 2025

/cc @MihaZupan

@krwq
Copy link
Member

krwq commented May 8, 2025

Let me post offline comment on behalf of @MihaZupan:

GetLeftPart is just a shorthand for picking the set of UriComponent flags to pass to GetComponents.

E.g. calling .GetLeftPart(UriPartial.Authority) is the same as calling
.GetComponents(UriComponents.Scheme | UriComponents.UserInfo | UriComponents.Host | UriComponents.Port, UriFormat.UriEscaped)
This is how basically all properties on Uri behave (Host, Query, PathAndQuery, AbsoluteUri, ...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Net untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

4 participants