summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2022-01-08 13:54:30 +0000
committerCalum Lind <calumlind+deluge@gmail.com>2022-01-08 13:56:05 +0000
commit79b7e6093f42de5a2dbf429f781fd3606a8f9e2e (patch)
tree15730aba54995a9aa7c6e7532add7c551a0b2085
parent4f0c786649ed80f5410173928d9370ac49d72ea3 (diff)
downloaddeluge-79b7e6093f42de5a2dbf429f781fd3606a8f9e2e.tar.gz
deluge-79b7e6093f42de5a2dbf429f781fd3606a8f9e2e.tar.bz2
deluge-79b7e6093f42de5a2dbf429f781fd3606a8f9e2e.zip
Fix is_url and is_infohash error with None value
Encountered a TypeError with None value passed to is_infohash function so add guard clause.
-rw-r--r--deluge/common.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/deluge/common.py b/deluge/common.py
index 509e5c355..66bf1d12e 100644
--- a/deluge/common.py
+++ b/deluge/common.py
@@ -699,6 +699,9 @@ def is_url(url):
True
"""
+ if not url:
+ return False
+
return url.partition('://')[0] in ('http', 'https', 'ftp', 'udp')
@@ -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()