-
Notifications
You must be signed in to change notification settings - Fork 984
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
Version metadata field size limits #14965
Comments
There's no current limit. See #12483 for previous report of this issue, and the conclusion that we should probably adhere to a PEP standard, but none exist yet. In regards to the parsing and sorting inefficiency, what do you have in mind? |
Currently the packaging To make numbers sortable in that scenario one has to prefix them with their encoded length. Some examples:
So a version string like
So the result would be For These sort correctly as strings: >>> "A0A1B20B11@bA1!~!" > "A0A1B20B11@bA1@postA1~!"
False
>>> "A0A1B20B11@bA1!~!" < "A0A1B20B11@bA1@postA1~!"
True
>>> parse_version("1.20.11.b1") > parse_version("1.20.11.b1.post1")
False
>>> parse_version("1.20.11.b1") < parse_version("1.20.11.b1.post1")
True In devpi and on pypi.org Open question would be what to do with integers with more than the encodable digits (52-61)? From the linked tickets there don't seem to be any relevant ones and we could store the version as a string prefixed by |
I made a first draft implementation: fschulze/devpi@9448085 |
Are there currently any enforced limits on the version string in metadata? I looked through the code, but couldn't find anything.
With no limit we can get denial of service attacks, only with Python 3.11 this is mitigated to some extend. See https://docs.python.org/3/library/stdtypes.html#int-max-str-digits, which in practice would apply a limit of 4300 digits per number element of a version.
My initial motivation was database side sorting in devpi. It is possible to construct comparable version strings, but they require the order of magnitude for numbers (see https://stackoverflow.com/a/30752452/3748142) and without limits this isn't possible. Also see the currently inefficient ordering in warehouse:
warehouse/warehouse/forklift/legacy.py
Lines 1176 to 1190 in 6d4b6a3
The text was updated successfully, but these errors were encountered: