Skip to content

[Filesystem] Path::isAbsolute() returns false if repetitive forward slashes are encountered exactly after driver for Windows paths #45485

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

Closed
machitgarha opened this issue Feb 19, 2022 · 13 comments

Comments

@machitgarha
Copy link

Symfony version(s) affected

5.4.0, 6.0.0

Description

If an absolute path has more than one forward slashes exactly next to the Windows drive, the path is detected as not being absolute. Backward slashes are not problematic at all, and also forward slashes, except the current case.

For instance, calling Path::isAbsolute() on 'C://users/' will return false, but for both 'C:/users//' and 'C:\\\\users/', true is returned.

How to reproduce

Run the following PHP codes:

Path::isAbsolute('E://test');
Path::isAbsolute('C:///windows');
Path::isAbsolute(
    Path::join('C:', '\\users')
);

Possible Solution

No response

Additional Context

No response

@JabriAbdelilah
Copy link
Contributor

@machitgarha in Path.php they are striping the ://, it seems like it is a wanted behavior.

If not, I can make a PR to remove that striping and return true if we have X:// (X is an alphabetic character)

PS: C:///windows should pass

@machitgarha
Copy link
Author

machitgarha commented Feb 20, 2022

@JabriAbdelilah, I don't think so. What I think is :// specifies the domain of the path, for example admin:// or vnc://.

@carsonbot
Copy link

Hey, thanks for your report!
There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?

@machitgarha
Copy link
Author

The bug is still relevant. I've not found a workaround yet.

@carsonbot carsonbot removed the Stalled label Aug 28, 2022
@carsonbot
Copy link

Hey, thanks for your report!
There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?

@machitgarha
Copy link
Author

Still relevant.

@carsonbot carsonbot removed the Stalled label Mar 2, 2023
@carsonbot
Copy link

Hey, thanks for your report!
There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?

@carsonbot
Copy link

Friendly reminder that this issue exists. If I don't hear anything I'll close this.

@machitgarha
Copy link
Author

Friendly response, not fixed yet.

@carsonbot carsonbot removed the Stalled label Oct 1, 2023
@nicolas-grekas
Copy link
Member

Would you like to give a fix a try? The issue won't fix itself by keeping it open ;)

@machitgarha
Copy link
Author

Umm... Maybe later, 'cause it's been a long time since encountering the issue (almost one year).

But... The issue should be open as long as it is unresolved, shouldn't it?

@xabbuh
Copy link
Member

xabbuh commented Apr 29, 2024

Can you confirm that #54759 fixes this?

@fabpot fabpot closed this as completed May 1, 2024
fabpot added a commit that referenced this issue May 1, 2024
…ive letters (xabbuh)

This PR was merged into the 5.4 branch.

Discussion
----------

[Filesystem] better distinguish URL schemes and Windows drive letters

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #45485
| License       | MIT

Commits
-------

f456e75 better distinguish URL schemes and windows drive letters
@machitgarha
Copy link
Author

@xabbuh, yes, the added test (if passed) shows it's fixed. Thanks. :)

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

No branches or pull requests

6 participants