From 5188750332a09c87939224c1d6c1c4f1eeb187e9 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Thu, 27 Sep 2012 18:36:50 +0100 Subject: [PATCH] Fix 2163 : Cannot add torrent file with empty (0:) encoding tag --- deluge/ui/common.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/deluge/ui/common.py b/deluge/ui/common.py index 239bb84c9..3b754cef7 100644 --- a/deluge/ui/common.py +++ b/deluge/ui/common.py @@ -77,11 +77,13 @@ 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" + self.encoding = None if "encoding" in self.__m_metadata: self.encoding = self.__m_metadata["encoding"] elif "codepage" in self.__m_metadata: self.encoding = str(self.__m_metadata["codepage"]) + if not self.encoding: + self.encoding = "UTF-8" # Check if 'name.utf-8' is in the torrent and if not try to decode the string # using the encoding found.