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:32:03 +0100 |
commit | 67873f39dc5b58dbd16c49850f45e9e53be9daf4 (patch) | |
tree | 5f9978eacb2632665b974eaf14833eec721eb509 /deluge/ui/common.py | |
parent | 7aa52e5f1bdbca433113ed6eab73a1d0c4f89348 (diff) | |
download | deluge-67873f39dc5b58dbd16c49850f45e9e53be9daf4.tar.gz deluge-67873f39dc5b58dbd16c49850f45e9e53be9daf4.tar.bz2 deluge-67873f39dc5b58dbd16c49850f45e9e53be9daf4.zip |
[#2418] Fix WebUI error when adding non-ascii torrent
json.dumps attempts to decode (utf8) the 'path' entry which had a
alternative 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.
Diffstat (limited to 'deluge/ui/common.py')
-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 3e0064027..355d33d60 100644 --- a/deluge/ui/common.py +++ b/deluge/ui/common.py @@ -98,8 +98,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 = utf8_encoded(os.path.join(prefix, utf8_encoded(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') @@ -155,12 +157,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 = utf8_encoded(os.path.join(prefix, utf8_encoded(os.path.join(*f["path"]), self.encoding)), self.encoding) self.__m_files.append({ - 'path': path, + 'path': f["path"], 'size': f["length"], 'download': True }) |