Repository navigation
fix(pypa-index): escape for href tag requires-python - #153
Merged
Merged
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.
Summary
The generated
pytorch-wheelsPyPA Simple indexes corrupt HTML-encodedrequires-pythonvalues while parsing and re-rendering upstream PyTorch index pages.Upstream PyTorch HTML:
Our generated HTML:
Our generated JSON:
After one HTML decoding pass, clients receive the literal string
>=3.10rather than>=3.10. This is not a valid Python version specifier.For the live
filelockindex, all 170 entries carryingrequires-pythonwere affected.Reproduction
Create a temporary project:
Run:
Observed output:
The version exists in the generated index, but
uvdiscards it because itsrequires-pythonvalue is malformed.Root cause
crates/pypa-simple/src/lib.rs::parse_anchorsreads HTML attribute values fromtlwithout decoding character references.render_projectthen HTML-escapes those already encoded strings again.This affects
data-requires-python,data-yankedreasons and query strings inhrefHTML tag.The correct behavior is to decode HTML entities once when importing attributes into the internal model, then escape them once when serializing HTML.
Other routes
astral-wheelscurrently receives JSON-origin metadata and is unaffected in tested indexes: 8/8requires-pythonvalues were valid>=3.10. The parser fix should nevertheless cover any HTML-origin Astral pages./pypi/web/simpleproxies upstream HTML without parsing/re-rendering it and preservesrequires-pythoncorrectly./pypi-packagesis an artifact route, not an index, and does not itself carryrequires-python.