-
Notifications
You must be signed in to change notification settings - Fork 8k
Fix GH-19311: Unexpected path truncation of files contained in a tar file by PharData::extractTo() #19322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ndossche
wants to merge
3
commits into
php:master
Choose a base branch
from
ndossche:phar-pax
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix GH-19311: Unexpected path truncation of files contained in a tar file by PharData::extractTo() #19322
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| --TEST-- | ||
| GH-19311 (Unexpected path truncation of files contained in a tar file by PharData::extractTo()) | ||
| --EXTENSIONS-- | ||
| phar | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| $tar = new PharData(__DIR__ . '/../files/gh19311/pax_local_path_override.tar'); | ||
| foreach (new RecursiveIteratorIterator($tar) as $file) { | ||
| echo $file->getPathname(), "\n"; | ||
| } | ||
|
|
||
| ?> | ||
| --EXPECTF-- | ||
| phar://%s/pax_local_path_override.tar/a-very-long-path/to-a-file/with-a-very-long-name/in-a-deep-directory-structure/a-php-file-with-a-very-long-name.php |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --TEST-- | ||
| Global hdrcharset | ||
| --EXTENSIONS-- | ||
| phar | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| $tar = new PharData(__DIR__ . '/../files/gh19311/global_hdrcharset.tar'); | ||
| foreach (new RecursiveIteratorIterator($tar) as $file) { | ||
| echo $file->getPathname(), "\n"; | ||
| } | ||
|
|
||
| ?> | ||
| --EXPECTF-- | ||
| Notice: PharData::__construct(): Global PAX header component not understood: invalid header character set in %s on line %d | ||
| phar://%s/global_hdrcharset.tar/example.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --TEST-- | ||
| Global path override with PAX header | ||
| --EXTENSIONS-- | ||
| phar | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| try { | ||
| new PharData(__DIR__ . '/../files/gh19311/global_path_override.tar'); | ||
| } catch (UnexpectedValueException $e) { | ||
| echo $e->getMessage(), "\n"; | ||
| } | ||
|
|
||
| ?> | ||
| --EXPECTF-- | ||
| phar error: "%s" is a corrupted tar file (invalid global pax header: unsupported global path override) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --TEST-- | ||
| Local hdrcharset | ||
| --EXTENSIONS-- | ||
| phar | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| $tar = new PharData(__DIR__ . '/../files/gh19311/local_hdrcharset.tar'); | ||
| foreach (new RecursiveIteratorIterator($tar) as $file) { | ||
| echo $file->getPathname(), "\n"; | ||
| } | ||
|
|
||
| ?> | ||
| --EXPECTF-- | ||
| Notice: PharData::__construct(): File PAX header component not understood: invalid header character set in %s on line %d | ||
| phar://%s/local_hdrcharset.tar/example.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --TEST-- | ||
| Path edge case | ||
| --EXTENSIONS-- | ||
| phar | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| $tar = new PharData(__DIR__ . '/../files/gh19311/path_edge_case.tar'); | ||
| foreach (new RecursiveIteratorIterator($tar) as $file) { | ||
| echo $file->getPathname(), "\n"; | ||
| } | ||
|
|
||
| ?> | ||
| --EXPECTF-- | ||
| Notice: PharData::__construct(): File PAX header component not understood: invalid path length in %s on line %d | ||
| phar://%s/path_edge_case.tar/example.txt |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly move where the
bail:label is? It is somewhat confusing that we go "back up" to do error handling rather than the usual "go to end of function" style for error handling. As I needed to look up the full function code to locate the label.May be a follow-up PR/commit or be a new commit in this change set.