Skip to content

Commit

Permalink
explain why we don't validate hexdigests now
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed May 12, 2022
1 parent bd94548 commit 69e28eb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/pip/_internal/models/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class LinkHash:
value: str

_hash_re = re.compile(
# NB: we do not validate that the second group (.*) is a valid hex
# digest. Instead, we simply keep that string in this class, and then check it
# against Hashes when hash-checking is needed. This is easier to debug than
# proactively discarding an invalid hex digest, as we handle incorrect hashes
# and malformed hashes in the same place.
r"({choices})=(.*)".format(
choices="|".join(re.escape(hash_name) for hash_name in _SUPPORTED_HASHES)
),
Expand Down

0 comments on commit 69e28eb

Please sign in to comment.