Skip to content

Commit

Permalink
Fix is_url and is_infohash error with None value
Browse files Browse the repository at this point in the history
Encountered a TypeError with None value passed to is_infohash function
so add guard clause.
  • Loading branch information
cas-- committed Jan 8, 2022
1 parent 4f0c786 commit 79b7e60
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions deluge/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,9 @@ def is_url(url):
True
"""
if not url:
return False

return url.partition('://')[0] in ('http', 'https', 'ftp', 'udp')


Expand All @@ -713,6 +716,9 @@ def is_infohash(infohash):
bool: True if valid infohash, False otherwise.
"""
if not infohash:
return False

return len(infohash) == 40 and infohash.isalnum()


Expand Down

0 comments on commit 79b7e60

Please sign in to comment.