Skip to content

Fix 8861 properly #8869

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

Merged
merged 3 commits into from
Jun 28, 2022
Merged

Fix 8861 properly #8869

merged 3 commits into from
Jun 28, 2022

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Jun 25, 2022

I don't know how to GitHub and push to the fork branch so ... new PR.

@m-vo Have a look if this does the job

Copy link
Contributor

@m-vo m-vo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM by what I can tell. 👍

Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Knowing nothing about SplFileInfo, does this account for Windows paths?

@@ -651,14 +651,17 @@ static inline HashTable *spl_filesystem_object_get_debug_info(zend_object *objec
pnstr = spl_gen_private_prop_name(spl_ce_SplFileInfo, "fileName", sizeof("fileName")-1);
path = spl_filesystem_object_get_path(intern);

if (ZSTR_LEN(path) && ZSTR_LEN(path) < ZSTR_LEN(intern->file_name)) {
if (path && ZSTR_LEN(path) && ZSTR_LEN(path) < ZSTR_LEN(intern->file_name)) {
/* +1 to skip the trailing / of the path in the file name */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't that be a leading slash?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this behaves differently on a windows machine, but \SplFileInfo IMHO always only worked properly with forward slashes. See https://3v4l.org/lsPaS.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't that be a leading slash?

Huuum maybe it's wording, I used trailing as in 'foo/bar.baz' the path is foo so we need to skip the slash just after foo therefore trailing the path?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this behaves differently on a windows machine, but \SplFileInfo IMHO always only worked properly with forward slashes. See https://3v4l.org/lsPaS.

Great, more reasons for me to hate SPL :|

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, that works as expected on Windows (3v4l.org runs Linux).

@m-vo
Copy link
Contributor

m-vo commented Jun 27, 2022

Not sure if this behaves differently on a windows machine, but \SplFileInfo IMHO always only worked properly with forward slashes. See https://3v4l.org/lsPaS.

Apparently, when executed on windows, both separators work
(the output would be bar.baz for both variants)... 🙈

@fritzmg
Copy link

fritzmg commented Jun 27, 2022

This should be true for all file related operations in the PHP core.

@m-vo
Copy link
Contributor

m-vo commented Jun 28, 2022

The behavior on windows (and the discussion whether its correct or not) should probably be handled in a different PR/RFC. I'd vote for merging this PR as is. 👍

@Girgias
Copy link
Member Author

Girgias commented Jun 28, 2022

This should be true for all file related operations in the PHP core.

This is not possible the name ab\cd.txt is a valid file name on Linux (just do touch ab\\cd.txt)

@Girgias Girgias merged commit 9bae9ab into php:master Jun 28, 2022
@Girgias Girgias deleted the fix-8862 branch June 28, 2022 14:43
@fritzmg
Copy link

fritzmg commented Jun 28, 2022

This is not possible the name ab\cd.txt is a valid file name on Linux (just do touch ab\\cd.txt)

My comment was just generally speaking. I meant: all file related PHP operations are agnostic towards the usage of a forward or backward slash as a directory separator under Windows, including things like file_exists, is_file and - specifically for this issue, SplFileInfo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants