Skip to content

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

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy