Merge pull request #1242 from hydrusnetwork/system-hash-pred-parser-regex-fix

regex fix for system:hash in predicate parser
This commit is contained in:
Hydrus Network Developer 2022-09-27 20:27:26 -05:00 committed by GitHub
commit 163056ae99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -282,7 +282,7 @@ def parse_value( string: str, spec ):
return string[ len( match[ 0 ] ): ], (hashes, distance)
raise ValueError( "Invalid value, expected a list of hashes with distance" )
elif spec == Value.HASHLIST_WITH_ALGORITHM:
match = re.match( '(?P<hashes>[0-9a-f]+((\s|,)+[0-9a-f]+)*)((with\s+)?algorithm)?\s*(?P<algorithm>sha256|sha512|md5|sha1|)', string )
match = re.match( '(?P<hashes>([0-9a-f]+(\s|,)+)+)((with\s+)?algorithm)?\s*(?P<algorithm>sha256|sha512|md5|sha1|)', string )
if match:
hashes = set( hsh.strip() for hsh in re.sub( '\s', ' ', match[ 'hashes' ].replace( ',', ' ' ) ).split( ' ' ) if len( hsh ) > 0 )
algorithm = match[ 'algorithm' ] if len( match[ 'algorithm' ] ) > 0 else 'sha256'