From fa2816b89d52f2af7b99c2e80dd1655d35df0822 Mon Sep 17 00:00:00 2001 From: Torsten Werner Date: Tue, 1 Mar 2011 22:07:03 +0100 Subject: [PATCH] Support utf-8 encoding as a primary encoding for filenames. Signed-off-by: Torsten Werner --- daklib/dbconn.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/daklib/dbconn.py b/daklib/dbconn.py index aab02513..b1093eea 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -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() -- 2.39.2