[#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.
This commit is contained in:
Calum Lind 2016-10-14 11:48:31 +01:00
parent 9dd3b1617d
commit b4787235b5
1 changed files with 3 additions and 4 deletions

View File

@ -665,7 +665,8 @@ class AddTorrentDialog(component.Component):
entry.grab_focus() entry.grab_focus()
dialog.show_all() dialog.show_all()
response = dialog.run() 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 = [] trackers = []
b = textview.get_buffer() b = textview.get_buffer()
lines = b.get_text(b.get_start_iter(), b.get_end_iter()).strip().split("\n") 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 # Convert the information to a magnet uri, this is just easier to
# handle this way. # handle this way.
log.debug("trackers: %s", trackers) log.debug("trackers: %s", trackers)
magnet = deluge.common.create_magnet_uri( magnet = deluge.common.create_magnet_uri(infohash, infohash, trackers)
infohash=entry.get_text().decode("utf-8"),
trackers=trackers)
log.debug("magnet uri: %s", magnet) log.debug("magnet uri: %s", magnet)
self.add_from_magnets([magnet]) self.add_from_magnets([magnet])