diff options
author | Andrew Resch <andrewresch@gmail.com> | 2009-04-05 18:31:43 +0000 |
---|---|---|
committer | Andrew Resch <andrewresch@gmail.com> | 2009-04-05 18:31:43 +0000 |
commit | e8d9c43b48536727d36af8fb8fd78add6cb8cc0f (patch) | |
tree | e5f663cc4131bf3df636fe42cdaa7c53385e6722 | |
parent | 8d8e1ef5c34d51119283bac3a729c2892e1c5c8b (diff) | |
download | deluge-e8d9c43b48536727d36af8fb8fd78add6cb8cc0f.tar.gz deluge-e8d9c43b48536727d36af8fb8fd78add6cb8cc0f.tar.bz2 deluge-e8d9c43b48536727d36af8fb8fd78add6cb8cc0f.zip |
Fix displaying torrents with non-utf8 encodings in add torrent dialog
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | deluge/ui/common.py | 13 |
2 files changed, 12 insertions, 4 deletions
@@ -4,6 +4,9 @@ * Fix #855 force a resume on a torrent if a 'Force Recheck' is initiated * Fix #862 deluged crash when access http://localhost:58846 +==== GtkUI ==== + * Fix displaying torrents with non-utf8 encodings in add torrent dialog + ==== WebUI ==== * Fix #870 use proper config location for loading ssl cert diff --git a/deluge/ui/common.py b/deluge/ui/common.py index f0a5c5603..20ac3cc6c 100644 --- a/deluge/ui/common.py +++ b/deluge/ui/common.py @@ -46,29 +46,34 @@ class TorrentInfo(object): self.__m_info_hash = sha(bencode.bencode(self.__m_metadata["info"])).hexdigest() + # Get encoding from torrent file if available + self.encoding = "UTF-8" + if "encoding" in self.__m_metadata: + self.encoding = self.__m_metadata["encoding"] + # Get list of files from torrent info self.__m_files = [] if self.__m_metadata["info"].has_key("files"): prefix = "" if len(self.__m_metadata["info"]["files"]) > 1: - prefix = self.__m_metadata["info"]["name"] + prefix = self.__m_metadata["info"]["name"].decode(self.encoding).encode("utf8") for f in self.__m_metadata["info"]["files"]: self.__m_files.append({ - 'path': os.path.join(prefix, *f["path"]), + 'path': os.path.join(prefix, *f["path"]).decode(self.encoding).encode("utf8"), 'size': f["length"], 'download': True }) else: self.__m_files.append({ - "path": self.__m_metadata["info"]["name"], + "path": self.__m_metadata["info"]["name"].decode(self.encoding).encode("utf8"), "size": self.__m_metadata["info"]["length"], "download": True }) @property def name(self): - return self.__m_metadata["info"]["name"] + return self.__m_metadata["info"]["name"].decode(self.encoding).encode("utf8") @property def info_hash(self): |