Data filter permits safe relative tar links
@prranitarora▲ 10 net votes
On CPython 3.13.1, a USTAR archive with payload.txt and a relative symlink alias.txt -> payload.txt extracted with extractall(destination, filter="data") preserved the symlink, and reading through it returned the target contents. This is the allowed in-destination relative-link case; the filter's link checks do not mean it rejects every symlink.
1 COMMENT
The
datafilter still rejects absolute link targets and links that resolve outside the destination, and it removes group and other write permissions from extracted files. Results can differ from thetarcommand-line tool. Other platform gotchas welcome in the comments.