summaryrefslogtreecommitdiffstats
path: root/deluge/ui
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2022-01-08 18:54:15 +0000
committerCalum Lind <calumlind+deluge@gmail.com>2022-01-08 19:43:40 +0000
commite50927f5759bc4752baf231ad464f34852587822 (patch)
treeac3b37f1770595073686b9fec777b1ebb78fe610 /deluge/ui
parent79b7e6093f42de5a2dbf429f781fd3606a8f9e2e (diff)
downloaddeluge-e50927f5759bc4752baf231ad464f34852587822.tar.gz
deluge-e50927f5759bc4752baf231ad464f34852587822.tar.bz2
deluge-e50927f5759bc4752baf231ad464f34852587822.zip
[GTK] Fix unable to prefetch magnet in thinclient
A UnicodeDecodeError is raised in transfer module when attempting to prefetch a magnet. This is result of passing a Python dict containing text bytes and raw bytes that cannot be decoded as utf-8 in rencode when recieving the message. This could be handled in rencode by returning raw bytes if decoding fails (perhaps with a strict mode?) however better to follow convention of encoding raw bytes in base64 in API calls. Fixed by retaining bencoding and encoding with base64 when sending result. Resolves: https://github.com/deluge-torrent/deluge/pull/334
Diffstat (limited to 'deluge/ui')
-rw-r--r--deluge/ui/gtk3/addtorrentdialog.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/deluge/ui/gtk3/addtorrentdialog.py b/deluge/ui/gtk3/addtorrentdialog.py
index 1c94a1e08..cf3851d6c 100644
--- a/deluge/ui/gtk3/addtorrentdialog.py
+++ b/deluge/ui/gtk3/addtorrentdialog.py
@@ -8,7 +8,7 @@
import logging
import os
-from base64 import b64encode
+from base64 import b64decode, b64encode
from xml.sax.saxutils import escape as xml_escape
from xml.sax.saxutils import unescape as xml_unescape
@@ -16,6 +16,7 @@ from gi.repository import Gtk
from gi.repository.GObject import TYPE_INT64, TYPE_UINT64
import deluge.component as component
+from deluge.bencode import bdecode
from deluge.common import (
create_magnet_uri,
decode_bytes,
@@ -268,6 +269,7 @@ class AddTorrentDialog(component.Component):
return
if metadata:
+ metadata = bdecode(b64decode(metadata))
info = TorrentInfo.from_metadata(metadata, [[t] for t in trackers])
self.files[info_hash] = info.files
self.infos[info_hash] = info.filedata