pub fn unpack_zip<R: Read + Seek>(
archive: ZipArchive<R>,
dest: &Path,
) -> Result<(), ZipError>Expand description
Unpacks a .zip archive into dest with sandbox-safe permissions and
symlink containment, used by both latexml_oxide and cortex_worker:
- Every entry path is validated via
ZipFile::enclosed_name()so../ absolute paths never land outsidedest(skipped with a counted Warning). - Regular files and directories are written without inheriting archive exec
or read-only mode bits, and permissions are normalized at the end
(
a-x,u+rwXon Unix; clearingreadonlyon non-Unix) so read-only archive directories (0555) never leave temp entries behind on drop and executable files (0755) lose their exec bits. - Symlinks are handled in a second pass after all files/dirs exist:
in-archive symlinks stay symlinks (resolving to their target’s text, via
make_enclosed_link), while symlinks whose target would escapedest(e.g.-> /etc/hostname) are written as plain text files with a counted Warning instead of failing the whole paper.