summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2016-10-14 11:48:31 +0100
committerCalum Lind <calumlind+deluge@gmail.com>2016-10-18 19:14:51 +0100
commitf57ee74ee2dd10cc886fb34498a43f606448dde6 (patch)
tree51eecb3e8d8564c5b9f977087de101c2edb9486a
parent798f5e2deb10ec94f99d4b0ad7110a5e6da2ef1d (diff)
downloaddeluge-f57ee74ee2dd10cc886fb34498a43f606448dde6.tar.gz
deluge-f57ee74ee2dd10cc886fb34498a43f606448dde6.tar.bz2
deluge-f57ee74ee2dd10cc886fb34498a43f606448dde6.zip
[#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.
-rw-r--r--deluge/ui/gtkui/addtorrentdialog.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/deluge/ui/gtkui/addtorrentdialog.py b/deluge/ui/gtkui/addtorrentdialog.py
index ddd075b40..e40e1e9b4 100644
--- a/deluge/ui/gtkui/addtorrentdialog.py
+++ b/deluge/ui/gtkui/addtorrentdialog.py
@@ -740,7 +740,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")
@@ -751,9 +752,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])