Repository navigation
Fix Unicode URL authority encoding with ports and userinfo - #841
Open
student-shivamm wants to merge 1 commit into
Open
student-shivamm wants to merge 1 commit into
student-shivamm wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What type of PR is this?
Description
Registering a Unicode hostname with an explicit port can raise
urllib3.exceptions.LocationParseErrorinstead of matching the same URL passedto Requests.
_clean_unicode()currently treats the full authority as DNSlabels, so
example.рф:8443becomesexample.xn--:8443-uye2a. Userinfo canlikewise become part of an encoded hostname label.
Separate userinfo and the port before applying the existing Punycode conversion
to hostname labels. This also fixes Unicode
add_passthru()prefixes whilepreserving the significance of credentials, ports and paths.
Minimal reproduction on master:
No new dependency or public API is added.
Related Issues
No existing matching issue found.
PR checklist
toxand all-filespre-commitchecks locally.Applicable configured pre-commit hooks pass for all three changed files.
Full Python 3.12 test runs pass with Requests 2.34.2 / urllib3 2.8.0 and with
Requests 2.30.0 / urllib3 1.26.20: 278 passed in each environment.
Other Python versions/full tox matrix were not run.
Mypy 2.4.0 reports the same three existing errors on pinned master and this
patch, in unchanged
matchers.pyandtest_recorder.py; it is not claimed to pass.Added/updated tests?
significant differences in authority/path components. The identical suite
on master yields 15 failed / 263 passed; the patch yields 278 passed.
All changed executable encoding lines are covered.