Improve HttpEnvironmentProxy uri parsing #121206
Merged
+22
−21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We have a test that the path may be present, but while that particular input happens to work, the parsing logic isn't actually accounting for paths as a possibility.
If the path/query/fragment contains
:or@, it'd break.This change strips out the path/query/fragment portion so that our
hostthat we pass toUriBuilderis more likely to be just the host.Hit in #121083 that tries to add more validation to the
UriBuilder.Hostsetter.This does break some weird edge cases that we happened to support currently, e.g.
host:8080abc(garbage after the port).But I kept other weird cases like
user:p@ss@hostas-is (@as part of user info), which does mean that a@in the path can still break things.Ideally this method would be using
Uri.TryCreateinstead, but we currently accept some interesting inputs likedomain\foo:[email protected], so we'd still have to do some manual processing.dotnet/corefx#31232 (comment)