Commit 98252c96 authored by Jason R. Coombs's avatar Jason R. Coombs

Add a _repair method to repair the FileList after unsafe entries have been added.

parent afa18c94
...@@ -215,6 +215,16 @@ class FileList(_FileList): ...@@ -215,6 +215,16 @@ class FileList(_FileList):
def extend(self, paths): def extend(self, paths):
self.files.extend(filter(self._safe_path, paths)) self.files.extend(filter(self._safe_path, paths))
def _repair(self):
"""
Replace self.files with only safe paths
Because some owners of FileList manipulate the underlying
``files`` attribute directly, this method must be called to
repair those paths.
"""
self.files = list(filter(self._safe_path, self.files))
def _safe_path(self, path): def _safe_path(self, path):
if not PY3: if not PY3:
return os.path.exists(path) return os.path.exists(path)
...@@ -257,6 +267,8 @@ class manifest_maker(sdist): ...@@ -257,6 +267,8 @@ class manifest_maker(sdist):
Write the file list in 'self.filelist' to the manifest file Write the file list in 'self.filelist' to the manifest file
named by 'self.manifest'. named by 'self.manifest'.
""" """
self.filelist._repair()
files = [f.replace(os.sep, '/') for f in self.filelist.files] files = [f.replace(os.sep, '/') for f in self.filelist.files]
msg = "writing manifest file '%s'" % self.manifest msg = "writing manifest file '%s'" % self.manifest
self.execute(write_file, (self.manifest, files), msg) self.execute(write_file, (self.manifest, files), msg)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment