diff options
author | Calum Lind <calumlind+deluge@gmail.com> | 2014-07-08 14:56:31 +0100 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2014-07-08 15:31:49 +0100 |
commit | 8c4a08bb87a665c2039029ff0b2efdfe696d0f17 (patch) | |
tree | dc0ef799a3ec89c654504b58fe36a76386022ac9 | |
parent | 34650f4b3c58240248dea099c93ab5848e8bd778 (diff) | |
download | deluge-8c4a08bb87a665c2039029ff0b2efdfe696d0f17.tar.gz deluge-8c4a08bb87a665c2039029ff0b2efdfe696d0f17.tar.bz2 deluge-8c4a08bb87a665c2039029ff0b2efdfe696d0f17.zip |
[#2418] Fix WebUI error when adding non-ascii torrent
json.dumps attempts to decode (utf8) the 'path' entry which had a
different encoding. The solution is to ensure the 'path' entry is
utf8 encoded and remove the unneeded 'path.utf-8' entry.
As self.__m_metadata["info"]["files"] is updated the later code
checking and decoding the 'path' entry can be removed.
-rw-r--r-- | deluge/ui/common.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/deluge/ui/common.py b/deluge/ui/common.py index 59ae5fa08..968bb68e9 100644 --- a/deluge/ui/common.py +++ b/deluge/ui/common.py @@ -101,8 +101,10 @@ class TorrentInfo(object): for index, f in enumerate(self.__m_metadata["info"]["files"]): if "path.utf-8" in f: path = os.path.join(prefix, *f["path.utf-8"]) + del f["path.utf-8"] else: path = decode_string(os.path.join(prefix, decode_string(os.path.join(*f["path"]), self.encoding)), self.encoding) + f["path"] = path f["index"] = index if "sha1" in f and len(f["sha1"]) == 20: f["sha1"] = f["sha1"].encode('hex') @@ -158,12 +160,8 @@ class TorrentInfo(object): prefix = self.__m_name for f in self.__m_metadata["info"]["files"]: - if "path.utf-8" in f: - path = os.path.join(prefix, *f["path.utf-8"]) - else: - path = decode_string(os.path.join(prefix, decode_string(os.path.join(*f["path"]), self.encoding)), self.encoding) self.__m_files.append({ - 'path': path, + 'path': f["path"], 'size': f["length"], 'download': True }) |