-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Reset all Uri fields when reusing an instance #41324
Reset all Uri fields when reusing an instance #41324
Conversation
Tagging subscribers to this area: @dotnet/ncl |
cc: @ryalanms |
Thank you, @MihaZupan and @karelz, for the fast response and fix! |
cc @dotnet/wpf-developers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/backport to release/5.0 |
Started backporting to release/5.0: https://github.com/dotnet/runtime/actions/runs/225384771 |
Simplifying
OriginalString
to_originalUnicodeString ?? _string
in #33044 introduced a bug affecting thenew Uri(baseUri, relativeUri)
combine operations.The bug can be hit if:
relativeUri
contains non-ascii charactersbaseUri
uses a custom (not built-in scheme) - in this casepack
UriParser
is registered for that schemeGenericUriParser
, and it is set up without theGenericUriParserOptions.IriParsing
flagThe cause is that when combining the Uris, the Uri instance gets reused, but not all internal fields are reset. As
_originalUnicodeString
was not being reset, it changed the output ofOriginalString
when reused. This led to the relative Uri being used in the parsing logic instead of the constructed combined Uri.This does not affect built-in schemes / custom parsers with the
IriParsing
flag, as_originalUnicodeString
will be properly set during parsing (the old value won't sneak through).Fixes #41177