]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-104527: zippapp will now avoid appending an archive to itself. (gh-106076)
authorGabriel Venberg <gabevenberg@gmail.com>
Mon, 26 Jun 2023 09:09:08 +0000 (04:09 -0500)
committerGitHub <noreply@github.com>
Mon, 26 Jun 2023 09:09:08 +0000 (10:09 +0100)
zippapp will now avoid appending an archive to itself.

Lib/zipapp.py
Misc/NEWS.d/next/Library/2023-06-25-06-57-24.gh-issue-104527.TJEUkd.rst [new file with mode: 0644]

index d8ebfcb6c73b0c7bdec4c69a446d30e310526492..03a214efa10a20dcf1a54b611a0b83abb79b4265 100644 (file)
@@ -138,7 +138,7 @@ def create_archive(source, target=None, interpreter=None, main=None,
         with zipfile.ZipFile(fd, 'w', compression=compression) as z:
             for child in sorted(source.rglob('*')):
                 arcname = child.relative_to(source)
-                if filter is None or filter(arcname):
+                if filter is None or filter(arcname) and child.resolve() != arcname.resolve():
                     z.write(child, arcname.as_posix())
             if main_py:
                 z.writestr('__main__.py', main_py.encode('utf-8'))
diff --git a/Misc/NEWS.d/next/Library/2023-06-25-06-57-24.gh-issue-104527.TJEUkd.rst b/Misc/NEWS.d/next/Library/2023-06-25-06-57-24.gh-issue-104527.TJEUkd.rst
new file mode 100644 (file)
index 0000000..50b845b
--- /dev/null
@@ -0,0 +1 @@
+Zipapp will now skip over apending an archive to itself.