-
-
Notifications
You must be signed in to change notification settings - Fork 168
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
Explicit port 0 replaced with default port #1408
Comments
Thanks for the report! Outside of URLs, port 0 may have different semantics assigned. For example, it can be a so-called "ephemeral port" that is passed into the socket bind syscalls and then the kernel assigns an unoccupied port that nobody claimed, at which point it turns into a concrete port with a non-zero number. I can imagine that someone may want to represent a pre-binding URL for logging purposes. Or for when an interactive app doesn't bind to a port until a user clicks the button. I can also imagine So I'd say — send us an xfailing test and perhaps some Hypothesis tests, for starters. No rush, though — we're leading an aiohttp sprint day on Saturday and this might be a good issue for the participants to look into. |
It doesn't look like anybody picked this up... |
I can imagine the only usage for port 0: make an url that listens on any available port. |
Please confirm the following
vulnerability, to the best of my knowledge. (These must be shared by
submitting this report form instead, if
any hesitation exists.)
Describe the bug
If a URL has an explicit port of
0
and a scheme with a default port (such ashttp
), then theport
andexplicit_port
attributes disagree on what the port is.To Reproduce
Expected behavior
If
explicit_port
is notNone
, thenport
should be the same asexplicit_port
.Logs/tracebacks
Python Version
multidict Version
propcache Version
yarl Version
OS
Ubuntu 22.04
Additional context
I discovered this because Hypothesis can generate such a URL from its
hypothesis.provisional.urls
strategy. I think yarl's implementation ofport
(asself.explicit_port or self._default_port
) is wrong because the URL grammar permits the port to be 0 (the production is justport = *DIGIT
), but I can't think of a situation where a URL with port 0 would be useful.The text was updated successfully, but these errors were encountered: