Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9697434
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
View Options
diff --git a/swh/web/ui/query.py b/swh/web/ui/query.py
index ee5fc1d53..e2377bd76 100644
--- a/swh/web/ui/query.py
+++ b/swh/web/ui/query.py
@@ -1,40 +1,40 @@
# Copyright (C) 2015 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
import re
from swh.core import hashutil
# Regexp to filter and check inputs
-sha256_regexp='[0-9a-f]{64}'
-sha1_regexp='[0-9a-f]{40}'
+sha256_regexp = '[0-9a-f]{64}'
+sha1_regexp = '[0-9a-f]{40}'
def categorize_hash(hash):
"""Categorize the hash string according to what it is.
Args:
hash: hash string representation (sha1 or sha256)
Returns:
A dictionary of hash indexed by their nature (sha1, sha256)
The dictionary will be empty if nothing matches
Raises:
None
"""
try:
h = hashutil.hex_to_hash(hash)
except ValueError: # ignore silently to check the other inputs
return {}
if re.search(sha256_regexp, hash):
return {'sha256': h}
if re.search(sha1_regexp, hash):
return {'sha1': h}
return {}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Aug 18, 11:45 PM (2 w, 21 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3326524
Attached To
R65 Staging repository
Event Timeline
Log In to Comment