tar.py: Fix hardlink extraction with latest Python#2039
Conversation
Recent Python security fixes (included in 3.13.4 but also backported to older branches) require link targets to pass the specified filter function as well. This can result in hardlinked files to not be extracted when a `base-dir` is set. This commit separates the filtering from the extraction to avoid this issue. Pass `filter="tar"` as Python 3.14+ will default to the too restrictive `filter="data"`. python/cpython#135037 Fixes #2029.
|
Looking at python/cpython#135037, it looks like cpython is messing with extracted links, calling Your commit itself looks sensible, and addresses the mentioned test case where we are testing tarball behavior - however the behavioral change in python is deep and a bit worrying. Now that I'm seeing these @juergbi I think it is unlikely that python broke symlinks with this, I'll leave it up to you to decide whether you think we need to add more symlink coverage on our side, otherwise lets just go ahead with this merge. |
I've pushed a new test to verify that symlinks are supported and targets are not mangled. The new test passes without code changes. It would fail on Python 3.14 without |
Recent Python security fixes to the tarfile module (included in 3.13.4 but also backported to older branches) require link targets to pass the specified filter function as well. This can result in hardlinked files to not be extracted when a
base-diris set.This commit separates the filtering from the extraction to avoid this issue. Pass
filter="tar"as Python 3.14+ will default to the too restrictivefilter="data".python/cpython#135037
Fixes #2029.