From 79b7e6093f42de5a2dbf429f781fd3606a8f9e2e Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sat, 8 Jan 2022 13:54:30 +0000 Subject: [PATCH] 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. --- deluge/common.py | 6 ++++++ 1 file changed, 6 insertions(+) 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()