Skip to content

.GetLeftPart does unicode character encoding under the hood #11253

@erdembayar

Description

@erdembayar

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.

Activity

added
needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners
on Apr 28, 2025
changed the title [-].GetLeftPart does unicode encoding under the hood[/-] [+].GetLeftPart does unicode character encoding under the hood[/+] on Apr 28, 2025
added and removed
needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners
on Apr 28, 2025
dotnet-policy-service

dotnet-policy-service commented on Apr 28, 2025

@dotnet-policy-service
Contributor

Tagging subscribers to this area: @dotnet/ncl

liveans

liveans commented on Apr 28, 2025

@liveans
Member
krwq

krwq commented on May 8, 2025

@krwq
Member

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, ...)

added this to the Backlog milestone on Jun 19, 2025
removed
untriagedNew issue has not been triaged by the area owner
on Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

    Participants

    @krwq@jeffhandley@erdembayar@gewarren@liveans

    Issue actions

      .GetLeftPart does unicode character encoding under the hood · Issue #11253 · dotnet/dotnet-api-docs