[#2763] [GTKUI] Fix unhandled error with invalid magnet uri

This commit is contained in:
Calum Lind 2015-09-20 15:19:32 +01:00
parent e4f2a450d6
commit 58059300bd
1 changed files with 5 additions and 1 deletions

View File

@ -251,12 +251,16 @@ class AddTorrentDialog(component.Component):
for uri in uris: for uri in uris:
s = uri.split("&")[0][20:] s = uri.split("&")[0][20:]
info_hash = None
if len(s) == 32: if len(s) == 32:
info_hash = base64.b32decode(s).encode("hex") info_hash = base64.b32decode(s).encode("hex")
elif len(s) == 40: elif len(s) == 40:
info_hash = s info_hash = s
if info_hash is None:
log.error("Invalid info_hash in uri: %s", uri)
continue
if info_hash in self.infos: if info_hash in self.infos:
log.debug("Torrent already in list!") log.debug("Torrent already in list: %s", uri)
continue continue
name = None name = None
for i in uri.split("&"): for i in uri.split("&"):