Patchwork D2654: archival: fsdecode paths before passing to tar or zip objects

login
register
mail settings
Submitter phabricator
Date March 4, 2018, 6:34 p.m.
Message ID <124dfdf93eaff8b642cdbd29d500917d@localhost.localdomain>
Download mbox | patch
Permalink /patch/28959/
State Not Applicable
Headers show

Comments

phabricator - March 4, 2018, 6:34 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGbfe23afea361: archival: fsdecode paths before passing to tar or zip objects (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2654?vs=6573&id=6582

REVISION DETAIL
  https://phab.mercurial-scm.org/D2654

AFFECTED FILES
  mercurial/archival.py

CHANGE DETAILS




To: durin42, #hg-reviewers, pulkit, indygreg
Cc: mercurial-devel

Patch

diff --git a/mercurial/archival.py b/mercurial/archival.py
--- a/mercurial/archival.py
+++ b/mercurial/archival.py
@@ -21,6 +21,7 @@ 
     error,
     formatter,
     match as matchmod,
+    pycompat,
     scmutil,
     util,
     vfs as vfsmod,
@@ -171,13 +172,14 @@ 
             self.z = taropen('w|', fileobj=dest)
 
     def addfile(self, name, mode, islink, data):
+        name = pycompat.fsdecode(name)
         i = tarfile.TarInfo(name)
         i.mtime = self.mtime
         i.size = len(data)
         if islink:
             i.type = tarfile.SYMTYPE
             i.mode = 0o777
-            i.linkname = data
+            i.linkname = pycompat.fsdecode(data)
             data = None
             i.size = 0
         else:
@@ -218,7 +220,7 @@ 
                 dest.tell()
             except (AttributeError, IOError):
                 dest = tellable(dest)
-        self.z = zipfile.ZipFile(dest, r'w',
+        self.z = zipfile.ZipFile(pycompat.fsdecode(dest), r'w',
                                  compress and zipfile.ZIP_DEFLATED or
                                  zipfile.ZIP_STORED)
 
@@ -232,7 +234,7 @@ 
         self.date_time = time.gmtime(mtime)[:6]
 
     def addfile(self, name, mode, islink, data):
-        i = zipfile.ZipInfo(name, self.date_time)
+        i = zipfile.ZipInfo(pycompat.fsdecode(name), self.date_time)
         i.compress_type = self.z.compression
         # unzip will not honor unix file modes unless file creator is
         # set to unix (id 3).