File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change
1
+ Fix and improve the parsing of hashes embedded in URL fragments.
Original file line number Diff line number Diff line change @@ -61,13 +61,13 @@ class LinkHash:
61
61
# against Hashes when hash-checking is needed. This is easier to debug than
62
62
# proactively discarding an invalid hex digest, as we handle incorrect hashes
63
63
# and malformed hashes in the same place.
64
- r"({choices})=(.* )" .format (
64
+ r"[#&] ({choices})=([^&]+ )" .format (
65
65
choices = "|" .join (re .escape (hash_name ) for hash_name in _SUPPORTED_HASHES )
66
66
),
67
67
)
68
68
69
69
def __post_init__ (self ) -> None :
70
- assert self ._hash_re .match (f"{ self .name } ={ self .value } " )
70
+ assert self ._hash_re .match (f"# { self .name } ={ self .value } " )
71
71
72
72
@classmethod
73
73
@functools .lru_cache (maxsize = None )
Original file line number Diff line number Diff line change @@ -1051,6 +1051,18 @@ def expand_path(path: str) -> str:
1051
1051
"https://pypi.org/pip-18.0.tar.gz#sha256=aa113592bbe" ,
1052
1052
LinkHash ("sha256" , "aa113592bbe" ),
1053
1053
),
1054
+ (
1055
+ "https://pypi.org/pip-18.0.tar.gz#sha256=aa113592bbe&subdirectory=setup" ,
1056
+ LinkHash ("sha256" , "aa113592bbe" ),
1057
+ ),
1058
+ (
1059
+ "https://pypi.org/pip-18.0.tar.gz#subdirectory=setup&sha256=aa113592bbe" ,
1060
+ LinkHash ("sha256" , "aa113592bbe" ),
1061
+ ),
1062
+ # "xsha256" is not a valid algorithm, so we discard it.
1063
+ ("https://pypi.org/pip-18.0.tar.gz#xsha256=aa113592bbe" , None ),
1064
+ # Discard empty hash.
1065
+ ("https://pypi.org/pip-18.0.tar.gz#sha256=" , None ),
1054
1066
(
1055
1067
"https://pypi.org/pip-18.0.tar.gz#md5=aa113592bbe" ,
1056
1068
LinkHash ("md5" , "aa113592bbe" ),
You can’t perform that action at this time.
0 commit comments