Skip to content

[Filesystem] Several issues with Filesystem::makePathRelative #25023

Closed
@inso

Description

@inso
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version master

Looking at the code of Filesystem::makePathRelative method I have found several issues:

  • Stripping of drive letter for arguments is done regardless of host OS but directory separator normalization is done only for Windows hosts.
  • There is no drive check for Windows paths, hence for the following case result will be invalid: (new Filesystem())->makePathRelative('C:/aa/bb/cc', 'D:/aa/dd/..') produces 'bb/cc/'
  • (new Filesystem())->makePathRelative('/aa/bb/cc', '/aa') produces 'bb/cc/' which is wrong since '/aa/bb/cc' can be the file path, the presence of trailing slash in the result should be based on presence of trailing slash in the $endPath argument.

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