Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
|
6c38b4975a | 5 months ago |
@ -0,0 +1,104 @@
|
|||||||
|
diff -ur zipp-0.5.1.orig/test_zipp.py zipp-0.5.1/test_zipp.py
|
||||||
|
--- zipp-0.5.1.orig/test_zipp.py 2019-05-17 01:34:53.000000000 +1000
|
||||||
|
+++ zipp-0.5.1/test_zipp.py 2024-09-22 18:45:15.000000000 +1000
|
||||||
|
@@ -170,3 +170,20 @@
|
||||||
|
root = zipp.Path(zipfile_abcde)
|
||||||
|
assert (root / 'a').parent.at == ''
|
||||||
|
assert (root / 'a' / 'b').parent.at == 'a/'
|
||||||
|
+
|
||||||
|
+ def test_malformed_paths(self):
|
||||||
|
+ """
|
||||||
|
+ Path should handle malformed paths.
|
||||||
|
+ """
|
||||||
|
+ data = io.BytesIO()
|
||||||
|
+ zf = zipfile.ZipFile(data, "w")
|
||||||
|
+ zf.writestr("/one-slash.txt", b"content")
|
||||||
|
+ zf.writestr("//two-slash.txt", b"content")
|
||||||
|
+ zf.writestr("../parent.txt", b"content")
|
||||||
|
+ zf.filename = ''
|
||||||
|
+ root = zipp.Path(zf)
|
||||||
|
+ assert list(map(str, root.iterdir())) == [
|
||||||
|
+ 'one-slash.txt',
|
||||||
|
+ 'two-slash.txt',
|
||||||
|
+ 'parent.txt',
|
||||||
|
+ ]
|
||||||
|
diff -ur zipp-0.5.1.orig/zipp.py zipp-0.5.1/zipp.py
|
||||||
|
--- zipp-0.5.1.orig/zipp.py 2019-05-17 01:34:53.000000000 +1000
|
||||||
|
+++ zipp-0.5.1/zipp.py 2024-09-22 16:33:44.000000000 +1000
|
||||||
|
@@ -7,10 +7,67 @@
|
||||||
|
import posixpath
|
||||||
|
import zipfile
|
||||||
|
import functools
|
||||||
|
+import re
|
||||||
|
|
||||||
|
__metaclass__ = type
|
||||||
|
|
||||||
|
+class SanitizedNames:
|
||||||
|
+ """
|
||||||
|
+ ZipFile mix-in to ensure names are sanitized.
|
||||||
|
+ """
|
||||||
|
+
|
||||||
|
+ def namelist(self):
|
||||||
|
+ return list(map(self._sanitize, super().namelist()))
|
||||||
|
+
|
||||||
|
+ @staticmethod
|
||||||
|
+ def _sanitize(name):
|
||||||
|
+ r"""
|
||||||
|
+ Ensure a relative path with posix separators and no dot names.
|
||||||
|
+ Modeled after
|
||||||
|
+ https://github.com/python/cpython/blob/bcc1be39cb1d04ad9fc0bd1b9193d3972835a57c/Lib/zipfile/__init__.py#L1799-L1813
|
||||||
|
+ but provides consistent cross-platform behavior.
|
||||||
|
+ >>> san = SanitizedNames._sanitize
|
||||||
|
+ >>> san('/foo/bar')
|
||||||
|
+ 'foo/bar'
|
||||||
|
+ >>> san('//foo.txt')
|
||||||
|
+ 'foo.txt'
|
||||||
|
+ >>> san('foo/.././bar.txt')
|
||||||
|
+ 'foo/bar.txt'
|
||||||
|
+ >>> san('foo../.bar.txt')
|
||||||
|
+ 'foo../.bar.txt'
|
||||||
|
+ >>> san('\\foo\\bar.txt')
|
||||||
|
+ 'foo/bar.txt'
|
||||||
|
+ >>> san('D:\\foo.txt')
|
||||||
|
+ 'D/foo.txt'
|
||||||
|
+ >>> san('\\\\server\\share\\file.txt')
|
||||||
|
+ 'server/share/file.txt'
|
||||||
|
+ >>> san('\\\\?\\GLOBALROOT\\Volume3')
|
||||||
|
+ '?/GLOBALROOT/Volume3'
|
||||||
|
+ >>> san('\\\\.\\PhysicalDrive1\\root')
|
||||||
|
+ 'PhysicalDrive1/root'
|
||||||
|
+ Retain any trailing slash.
|
||||||
|
+ >>> san('abc/')
|
||||||
|
+ 'abc/'
|
||||||
|
+ Raises a ValueError if the result is empty.
|
||||||
|
+ >>> san('../..')
|
||||||
|
+ Traceback (most recent call last):
|
||||||
|
+ ...
|
||||||
|
+ ValueError: Empty filename
|
||||||
|
+ """
|
||||||
|
+
|
||||||
|
+ def allowed(part):
|
||||||
|
+ return part and part not in {'..', '.'}
|
||||||
|
|
||||||
|
+ # Remove the drive letter.
|
||||||
|
+ # Don't use ntpath.splitdrive, because that also strips UNC paths
|
||||||
|
+ bare = re.sub('^([A-Z]):', r'\1', name, flags=re.IGNORECASE)
|
||||||
|
+ clean = bare.replace('\\', '/')
|
||||||
|
+ parts = clean.split('/')
|
||||||
|
+ joined = '/'.join(filter(allowed, parts))
|
||||||
|
+ if not joined:
|
||||||
|
+ raise ValueError("Empty filename")
|
||||||
|
+ return joined + '/' * name.endswith('/')
|
||||||
|
+
|
||||||
|
class Path:
|
||||||
|
"""
|
||||||
|
A pathlib-compatible interface for zip files.
|
||||||
|
@@ -165,7 +222,7 @@
|
||||||
|
return self._next(parent_at)
|
||||||
|
|
||||||
|
def _names(self):
|
||||||
|
- return self._add_implied_dirs(self.root.namelist())
|
||||||
|
+ return self._add_implied_dirs(list(map(SanitizedNames._sanitize, self.root.namelist())))
|
||||||
|
|
||||||
|
if sys.version_info < (3,):
|
||||||
|
__div__ = __truediv__
|
@ -1,73 +0,0 @@
|
|||||||
* Sat Feb 18 2023 Lumír Balhar <lbalhar@redhat.com> - 3.14.0-1
|
|
||||||
- Update to 3.14.0 (rhbz#2171124)
|
|
||||||
|
|
||||||
* Fri Feb 10 2023 Lumír Balhar <lbalhar@redhat.com> - 3.13.0-1
|
|
||||||
- Update to 3.13.0 (rhbz#2168671)
|
|
||||||
|
|
||||||
* Thu Feb 09 2023 Lumír Balhar <lbalhar@redhat.com> - 3.12.1-1
|
|
||||||
- Update to 3.12.1 (rhbz#2167196)
|
|
||||||
|
|
||||||
* Mon Jan 30 2023 Lumír Balhar <lbalhar@redhat.com> - 3.12.0-1
|
|
||||||
- Update to 3.12.0 (rhbz#2165156)
|
|
||||||
|
|
||||||
* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 3.11.0-2
|
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
|
|
||||||
|
|
||||||
* Mon Nov 28 2022 Lumír Balhar <lbalhar@redhat.com> - 3.11.0-1
|
|
||||||
- Update to 3.11.0 (rhbz#2148541)
|
|
||||||
|
|
||||||
* Mon Oct 24 2022 Lumír Balhar <lbalhar@redhat.com> - 3.10.0-1
|
|
||||||
- Update to 3.10.0
|
|
||||||
Resolves: rhbz#2137172
|
|
||||||
|
|
||||||
* Mon Oct 24 2022 Lumír Balhar <lbalhar@redhat.com> - 3.9.1-1
|
|
||||||
- Update to 3.9.1
|
|
||||||
Resolves: rhbz#2137172
|
|
||||||
|
|
||||||
* Sun Oct 09 2022 Lumír Balhar <lbalhar@redhat.com> - 3.9.0-1
|
|
||||||
- Update to 3.9.0
|
|
||||||
Resolves: rhbz#2133213
|
|
||||||
|
|
||||||
* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 3.8.1-2
|
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
|
|
||||||
|
|
||||||
* Tue Jul 12 2022 Lumír Balhar <lbalhar@redhat.com> - 3.8.1-1
|
|
||||||
- Update to 3.8.1
|
|
||||||
Resolves: rhbz#2106391
|
|
||||||
|
|
||||||
* Mon Jun 13 2022 Python Maint <python-maint@redhat.com> - 3.8.0-2
|
|
||||||
- Rebuilt for Python 3.11
|
|
||||||
|
|
||||||
* Mon Apr 04 2022 Lumír Balhar <lbalhar@redhat.com> - 3.8.0-1
|
|
||||||
- Update to 3.8.0
|
|
||||||
Resolves: rhbz#2071401
|
|
||||||
|
|
||||||
* Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 3.7.0-2
|
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
|
|
||||||
|
|
||||||
* Mon Jan 03 2022 Lumír Balhar <lbalhar@redhat.com> - 3.7.0-1
|
|
||||||
- Update to 3.7.0
|
|
||||||
Resolves: rhbz#2036287
|
|
||||||
|
|
||||||
* Tue Oct 05 2021 Lumír Balhar <lbalhar@redhat.com> - 3.6.0-1
|
|
||||||
- Update to 3.6.0
|
|
||||||
Resolves: rhbz#2008627
|
|
||||||
|
|
||||||
* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.5.0-2
|
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
|
|
||||||
|
|
||||||
* Wed Jul 07 2021 Lumír Balhar <lbalhar@redhat.com> - 3.5.0-1
|
|
||||||
- Update to 3.5.0
|
|
||||||
Resolves: rhbz#1978839
|
|
||||||
|
|
||||||
* Wed Jun 30 2021 Lumír Balhar <lbalhar@redhat.com> - 3.4.1-1
|
|
||||||
- Unretired package with new upstream version
|
|
||||||
|
|
||||||
* Mon Aug 19 2019 Miro Hrončok <mhroncok@redhat.com> - 0.5.1-3
|
|
||||||
- Rebuilt for Python 3.8
|
|
||||||
|
|
||||||
* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.5.1-2
|
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
|
|
||||||
|
|
||||||
* Wed Jun 26 2019 Miro Hrončok <mhroncok@redhat.com> - 0.5.1-1
|
|
||||||
- Initial package
|
|
@ -1 +1 @@
|
|||||||
SHA512 (zipp-3.20.1.tar.gz) = ed89c46d39ce703e233929146ce78332bfdd40cfad204c070247882f144fd0ec370c7499ce682ede938593b18870fa1dce8d746a0457e93c38be485378d6b546
|
SHA512 (zipp-0.5.1.tar.gz) = d4486ae98159677cd481cddb3bd00d5d2237dc94f0f3129b03994800b0e136c12b05e02d2ca7d628043dabce323f34dd919b9ba731549656802527abdcfea120
|
||||||
|
Loading…
Reference in new issue