summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCalum Lind <calumlind@gmail.com>2018-11-16 11:24:15 +0000
committerCalum Lind <calumlind@gmail.com>2018-11-16 15:06:30 +0000
commitbf4244e8b22094d62bf429b4535c67940134af34 (patch)
tree0a6031fcdd3b66ffbba55140d08dd1ddf8234706
parent25cfd58792738b540edfd51cf1b0984f44388e67 (diff)
downloaddeluge-bf4244e8b22094d62bf429b4535c67940134af34.tar.gz
deluge-bf4244e8b22094d62bf429b4535c67940134af34.tar.bz2
deluge-bf4244e8b22094d62bf429b4535c67940134af34.zip
[GTK] Fix adding non-ascii torrents and paths on Py2
Added decode_bytes to all widgets returning text to ensure unicode on Python 2.
-rw-r--r--deluge/ui/gtk3/addtorrentdialog.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/deluge/ui/gtk3/addtorrentdialog.py b/deluge/ui/gtk3/addtorrentdialog.py
index 651f32bf6..b741c9d4d 100644
--- a/deluge/ui/gtk3/addtorrentdialog.py
+++ b/deluge/ui/gtk3/addtorrentdialog.py
@@ -515,8 +515,12 @@ class AddTorrentDialog(component.Component):
else:
options = {}
- options['download_location'] = self.download_location_path_chooser.get_text()
- options['move_completed_path'] = self.move_completed_path_chooser.get_text()
+ options['download_location'] = decode_bytes(
+ self.download_location_path_chooser.get_text()
+ )
+ options['move_completed_path'] = decode_bytes(
+ self.move_completed_path_chooser.get_text()
+ )
options['pre_allocate_storage'] = self.builder.get_object(
'chk_pre_alloc'
).get_active()
@@ -709,8 +713,10 @@ class AddTorrentDialog(component.Component):
response = chooser.run()
if response == Gtk.ResponseType.OK:
- result = chooser.get_filenames()
- self.config['default_load_path'] = chooser.get_current_folder()
+ result = [decode_bytes(f) for f in chooser.get_filenames()]
+ self.config['default_load_path'] = decode_bytes(
+ chooser.get_current_folder()
+ )
else:
chooser.destroy()
return
@@ -821,12 +827,12 @@ class AddTorrentDialog(component.Component):
dialog.show_all()
response = dialog.run()
- infohash = entry.get_text().strip()
+ infohash = decode_bytes(entry.get_text()).strip()
if response == Gtk.ResponseType.OK and is_infohash(infohash):
# Create a list of trackers from the textview buffer
tview_buf = textview.get_buffer()
- trackers_text = tview_buf.get_text(
- *tview_buf.get_bounds(), include_hidden_chars=False
+ trackers_text = decode_bytes(
+ tview_buf.get_text(*tview_buf.get_bounds(), include_hidden_chars=False)
)
log.debug('Create torrent tracker lines: %s', trackers_text)
trackers = list(trackers_tiers_from_text(trackers_text).keys())
@@ -876,7 +882,9 @@ class AddTorrentDialog(component.Component):
row = self.torrent_liststore.get_iter_first()
while row is not None:
torrent_id = self.torrent_liststore.get_value(row, 0)
- filename = xml_unescape(self.torrent_liststore.get_value(row, 2))
+ filename = xml_unescape(
+ decode_bytes(self.torrent_liststore.get_value(row, 2))
+ )
try:
options = self.options[torrent_id]
except KeyError: