Skip to content

Reject port numbers that aren't composed only of ASCII digits. #89

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

Merged
merged 3 commits into from
Nov 13, 2022
Merged

Conversation

kenballus
Copy link
Contributor

Parsing port numbers with int allows port numbers to be

  • padded with whitespace (ASCII or unicode)
  • preceded by a plus or minus sign
  • interrupted with underscores
  • composed of unicode digits

None of these behaviors are permitted by any of the URL specifications. This PR adds a check to make sure that ports get rejected if they contain any characters that aren't ASCII digits.

A similar bug was recently fixed in CPython's urllib.parse module.

Copy link
Member

@sethmlarson sethmlarson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Can we add a test case that verifies we don't regress on this fix?

@kenballus
Copy link
Contributor Author

Thank you! Can we add a test case that verifies we don't regress on this fix?

Done!

@sethmlarson sethmlarson merged commit 2ca4b01 into python-hyper:main Nov 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants