diff --git a/deluge/ui/gtkui/addtorrentdialog.py b/deluge/ui/gtkui/addtorrentdialog.py index 8b8d9c521..ddd075b40 100644 --- a/deluge/ui/gtkui/addtorrentdialog.py +++ b/deluge/ui/gtkui/addtorrentdialog.py @@ -253,7 +253,11 @@ class AddTorrentDialog(component.Component): s = uri.split("&")[0][20:] info_hash = None if len(s) == 32: - info_hash = base64.b32decode(s).encode("hex") + try: + info_hash = base64.b32decode(s.upper()).encode("hex") + except TypeError, ex: + log.debug("Invalid base32 magnet hash: %s, %s", s, ex) + continue elif len(s) == 40: info_hash = s if info_hash is None: diff --git a/deluge/ui/web/json_api.py b/deluge/ui/web/json_api.py index 8730b23b7..b1c8ef60d 100644 --- a/deluge/ui/web/json_api.py +++ b/deluge/ui/web/json_api.py @@ -732,7 +732,11 @@ class WebApi(JSONComponent): if param.startswith(xt_param): xt_hash = param[len(xt_param):] if len(xt_hash) == 32: - info_hash = base64.b32decode(xt_hash).encode("hex") + try: + info_hash = base64.b32decode(xt_hash.upper()).encode("hex") + except TypeError, ex: + log.debug("Invalid base32 magnet hash: %s, %s", xt_hash, ex) + break elif len(xt_hash) == 40: info_hash = xt_hash else: