Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Filesystem] Path::getDirectory() doesn't retrieve the correct $dirSeparatorPosition with multibyte #47137

Copy link
Copy link
Closed
@Aangrod

Description

@Aangrod
Issue body actions

Symfony version(s) affected

6.1, 6.2

Description

If a path has multibyte characters before the last directory separator, the returned path is cut at the wrong position.

How to reproduce

Run the following PHP codes :
Path::getDirectory("D:/Folder/Aééé/Subfolder");

It will return 'D:/Folder/Aééé/Su' instead of 'D:/Folder/Aééé'

Possible Solution

Replace strrpos with mb_strrpos at line 161 in Path.php :

if (false === ($dirSeparatorPosition = strrpos($path, '/'))) {
    return '';
}

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.