From 8c4a08bb87a665c2039029ff0b2efdfe696d0f17 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Tue, 8 Jul 2014 14:56:31 +0100 Subject: [#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. --- deluge/ui/common.py | 8 +++----- 1 file 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 }) -- cgit