Skip to content

zip: require remove_path to be shorter than the path it strips - #207

Closed
iliaal wants to merge 1 commit into
masterfrom
fix/zip-remove-path-exact-match
Closed

zip: require remove_path to be shorter than the path it strips#207
iliaal wants to merge 1 commit into
masterfrom
fix/zip-remove-path-exact-match

Conversation

@iliaal

@iliaal iliaal commented Jul 31, 2026

Copy link
Copy Markdown
Owner

zend_string_starts_with() also matches on equality, so the length check dropped in bcb05dc was load-bearing. A globbed path that equals remove_path now reads its own NUL terminator in the IS_SLASH test, falls into the non-slash branch and strips its whole length, so the entry lands in the archive under an empty name. Before the conversion the path was kept as-is, which is what 8.4 and 8.5 still do.

$zip->addGlob("$dir/*.txt", 0, ['remove_path' => "$dir/a.txt"]);
// a.txt is added as "", b.txt keeps its full path

@iliaal
iliaal force-pushed the fix/zip-remove-path-exact-match branch from 93c4bad to a8abb4f Compare July 31, 2026 14:43
The zend_string conversion in bcb05dc replaced the length check with
zend_string_starts_with(), which also matches on equality. A path equal to
remove_path then hits the non-slash branch, strips its whole length and
produces an empty archive entry name instead of keeping the path.

Closes phpGH-22973
@iliaal
iliaal force-pushed the fix/zip-remove-path-exact-match branch from a8abb4f to 1538d61 Compare July 31, 2026 14:44
@iliaal

iliaal commented Jul 31, 2026

Copy link
Copy Markdown
Owner Author

Promoted upstream as php#22973.

@iliaal iliaal closed this Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant