Skip to content

fix: reject bool/non-int port on URL construction - #1117

Open
Pitchfork-and-Torch wants to merge 1 commit into
encode:masterfrom
Pitchfork-and-Torch:cook/url-reject-bool-port
Open

Pitchfork-and-Torch wants to merge 1 commit into
encode:masterfrom
Pitchfork-and-Torch:cook/url-reject-bool-port

Conversation

@Pitchfork-and-Torch

Copy link
Copy Markdown

Summary

httpcore.URL(..., port=True) stored a bool port. Because isinstance(True, int) is True, bytes(url) silently became host:1. Reject bool and other non-int ports with TypeError.

Test plan

  • pytest tests/test_models.py::test_url_rejects_bool_port tests/test_models.py::test_url_rejects_non_int_port
  • Manual: URL(scheme=b'http', host=b'h', port=True, target=b'/') raises TypeError

isinstance(True, int) is True, so port=True was stored and bytes(url)
silently became host:1. Reject bool and other non-int ports with TypeError.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant