From b4787235b5d4a3d885d36a8d0820ada0a7354b47 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Fri, 14 Oct 2016 11:48:31 +0100 Subject: [PATCH] [#2901] [GTKUI] Strip whitespace from infohash entry before checks * Copy-pasting from web page can include extra space at end of string. * Also make minor change to populate the magnet name with infohash for nicer UI display. --- deluge/ui/gtkui/addtorrentdialog.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/deluge/ui/gtkui/addtorrentdialog.py b/deluge/ui/gtkui/addtorrentdialog.py index 4b9b4e140..d75f0f65b 100644 --- a/deluge/ui/gtkui/addtorrentdialog.py +++ b/deluge/ui/gtkui/addtorrentdialog.py @@ -665,7 +665,8 @@ class AddTorrentDialog(component.Component): entry.grab_focus() dialog.show_all() response = dialog.run() - if response == gtk.RESPONSE_OK and len(entry.get_text()) == 40: + infohash = entry.get_text().strip() + if response == gtk.RESPONSE_OK and len(infohash) == 40: trackers = [] b = textview.get_buffer() lines = b.get_text(b.get_start_iter(), b.get_end_iter()).strip().split("\n") @@ -676,9 +677,7 @@ class AddTorrentDialog(component.Component): # Convert the information to a magnet uri, this is just easier to # handle this way. log.debug("trackers: %s", trackers) - magnet = deluge.common.create_magnet_uri( - infohash=entry.get_text().decode("utf-8"), - trackers=trackers) + magnet = deluge.common.create_magnet_uri(infohash, infohash, trackers) log.debug("magnet uri: %s", magnet) self.add_from_magnets([magnet])