]> git.decadent.org.uk Git - dak.git/commitdiff
Support utf-8 encoding as a primary encoding for filenames.
authorTorsten Werner <twerner@debian.org>
Tue, 1 Mar 2011 21:07:03 +0000 (22:07 +0100)
committerTorsten Werner <twerner@debian.org>
Tue, 1 Mar 2011 21:07:03 +0000 (22:07 +0100)
Signed-off-by: Torsten Werner <twerner@debian.org>
daklib/dbconn.py

index aab025136f0b35139f6f1ef590d52b11ea921cb8..b1093eea38bd1e1cb702701c8f71b52950efc549 100755 (executable)
@@ -508,8 +508,8 @@ class DBBinary(ORMObject):
     def scan_contents(self):
         '''
         Yields the contents of the package. Only regular files are yielded and
-        the path names are normalized after converting them from iso8859-1
-        encoding.
+        the path names are normalized after converting them from either utf-8 or
+        iso8859-1 encoding.
         '''
         fullpath = self.poolfile.fullpath
         debdata = Popen(['dpkg-deb', '--fsys-tarfile', fullpath],
@@ -517,7 +517,11 @@ class DBBinary(ORMObject):
         tar = TarFile.open(fileobj = debdata, mode = 'r|')
         for member in tar.getmembers():
             if member.isfile():
-                yield normpath(member.name.decode('iso8859-1'))
+                try:
+                    name = member.name.decode('utf-8')
+                catch UnicodeDecodeError:
+                    name = member.name.decode('iso8859-1')
+                yield normpath(name)
         tar.close()
         debdata.close()