Author: andar

Revision: 5116

Log:
        Fix loading improperly created torrents with mismatched encodings

Diff:
Modified: branches/1.1.0_RC/ChangeLog
===================================================================
--- branches/1.1.0_RC/ChangeLog 2009-04-21 16:32:53 UTC (rev 5115)
+++ branches/1.1.0_RC/ChangeLog 2009-04-21 17:16:19 UTC (rev 5116)
@@ -1,12 +1,13 @@
 === Deluge 1.1.7 - (In Development) ===
 ==== Core ====
   * Fix issue where cannot resume torrent after doing a 'Pause All'
-  
+
 ==== GtkUI ====
   * Fix #883 segfault if locale is not using UTF-8 encoding
   * Fix for adding torrents with invalid filename encodings
   * Fix displaying IPv6 peers in the Peers tab
   * Fix starting the daemon in OS X
+  * Fix loading improperly created torrents with mismatched encodings
 
 === Deluge 1.1.6 - (06 April 2009) ===
 ==== Core ====

Modified: branches/1.1.0_RC/deluge/ui/common.py
===================================================================
--- branches/1.1.0_RC/deluge/ui/common.py       2009-04-21 16:32:53 UTC (rev 
5115)
+++ branches/1.1.0_RC/deluge/ui/common.py       2009-04-21 17:16:19 UTC (rev 
5116)
@@ -70,24 +70,24 @@
         if self.__m_metadata["info"].has_key("files"):
             prefix = ""
             if len(self.__m_metadata["info"]["files"]) > 1:
-                prefix = 
self.__m_metadata["info"]["name"].decode(self.encoding).encode("utf8")
+                prefix = 
self.__m_metadata["info"]["name"].decode(self.encoding, 
"replace").encode("utf8")
 
             for f in self.__m_metadata["info"]["files"]:
                 self.__m_files.append({
-                    'path': os.path.join(prefix, 
*f["path"]).decode(self.encoding).encode("utf8"),
+                    'path': os.path.join(prefix, 
*f["path"]).decode(self.encoding, "replace").encode("utf8"),
                     'size': f["length"],
                     'download': True
                 })
         else:
             self.__m_files.append({
-                "path": 
self.__m_metadata["info"]["name"].decode(self.encoding).encode("utf8"),
+                "path": 
self.__m_metadata["info"]["name"].decode(self.encoding, 
"replace").encode("utf8"),
                 "size": self.__m_metadata["info"]["length"],
                 "download": True
         })
 
     @property
     def name(self):
-        return 
self.__m_metadata["info"]["name"].decode(self.encoding).encode("utf8")
+        return self.__m_metadata["info"]["name"].decode(self.encoding, 
"replace").encode("utf8")
 
     @property
     def info_hash(self):

Modified: trunk/deluge/ui/common.py
===================================================================
--- trunk/deluge/ui/common.py   2009-04-21 16:32:53 UTC (rev 5115)
+++ trunk/deluge/ui/common.py   2009-04-21 17:16:19 UTC (rev 5116)
@@ -58,10 +58,10 @@
         if self.__m_metadata["info"].has_key("files"):
             prefix = ""
             if len(self.__m_metadata["info"]["files"]) > 1:
-                prefix = 
self.__m_metadata["info"]["name"].decode(self.encoding).encode("utf8")
+                prefix = 
self.__m_metadata["info"]["name"].decode(self.encoding, 
"replace").encode("utf8")
 
             for index, f in enumerate(self.__m_metadata["info"]["files"]):
-                path = os.path.join(prefix, 
*f["path"]).decode(self.encoding).encode("utf8")
+                path = os.path.join(prefix, *f["path"]).decode(self.encoding, 
"replace").encode("utf8")
                 f["index"] = index
                 paths[path] = f
 
@@ -75,24 +75,24 @@
             self.__m_files_tree = file_tree.get_tree()
         else:
             self.__m_files_tree = {
-                
self.__m_metadata["info"]["name"].decode(self.encoding).encode("utf8"): 
(self.__m_metadata["info"]["length"], True)
+                self.__m_metadata["info"]["name"].decode(self.encoding, 
"replace").encode("utf8"): (self.__m_metadata["info"]["length"], True)
             }
 
         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"].decode(self.encoding).encode("utf8")
+                prefix = 
self.__m_metadata["info"]["name"].decode(self.encoding, 
"replace").encode("utf8")
 
             for f in self.__m_metadata["info"]["files"]:
                 self.__m_files.append({
-                    'path': os.path.join(prefix, 
*f["path"]).decode(self.encoding).encode("utf8"),
+                    'path': os.path.join(prefix, 
*f["path"]).decode(self.encoding, "replace").encode("utf8"),
                     'size': f["length"],
                     'download': True
                 })
         else:
             self.__m_files.append({
-                "path": 
self.__m_metadata["info"]["name"].decode(self.encoding).encode("utf8"),
+                "path": 
self.__m_metadata["info"]["name"].decode(self.encoding, 
"replace").encode("utf8"),
                 "size": self.__m_metadata["info"]["length"],
                 "download": True
         })



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to