Review main Merged

89171[BUGFIX] Strip only existing prefix in PathUtility::stripPathSitePrefix()

Stefan Bürk CR +2 V +2 Normal +54 −27 updated 05/14/25, 07:18

Commit message

Current `PathUtility::stripPathSitePrefix()` implementation simple
stripped the length from `Environment::getPublicPath() . '/'` from
provided `$path`, even if `$path` never contained the public path
from the start aka path prefix leading to malformed path information
and other issues.

Second, even in case it has been stripped it does not deal with the
fact it could be that there are two `//` between the public path
prefix and the rest of the path, returning the stripped path with
and without a leading slash (`/`) which not every usage is aware of.

This change modifies the method to return the unmodifed `$path` if it
does not have the publicPath as prefix and otherwise strip the prefix
and removing eventually duplicated `/` when splitting the path.

Additionally, the stripped path is left-trimmed to ensure no leading
slash is returned.

Tests are added to check for the expected behaviour.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Christian Kuhn +1
    • Benni Mack +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Oliver Klee +1
    • Christian Kuhn +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 2

Files 2

Review log 1214

  1. Stefan Bürk uploaded patch set 1 04/18/25, 13:20

  2. core-ci voted on patch set 1 V -1 04/18/25, 13:54 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77942

  3. Stefan Bürk commented on patch set 1 04/18/25, 13:56

    Note failing functional tests reveales places where path prefix has been stripped wrong before, and still lead to green tests (using the exception for now). Not investigated, but should be done anyway and unrelated to this change.
  4. Stefan Bürk commented on patch set 1 04/24/25, 08:35

    Reply

    Done
  5. Stefan Bürk uploaded patch set 2 V -1 04/24/25, 08:48

  6. Stefan Bürk wrote 04/24/25, 08:48

    Unset private
  7. core-ci voted on patch set 2 V +1 04/24/25, 08:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/78104

  8. Stefan Bürk wrote 04/24/25, 08:56

    Removed reviewer Oliver Hader.
  9. Benni Mack voted on patch set 2 CR +1 V +1 04/24/25, 10:26

  10. Christian Kuhn voted on patch set 2 CR +1 V +1 04/24/25, 11:18

  11. Oliver Klee voted on patch set 2 V +1 04/24/25, 11:37

  12. Stefan Bürk voted on patch set 2 CR +2 V +2 04/24/25, 11:37

  13. Stefan Bürk merged patch set 3 04/24/25, 11:46

  14. Stefan Bürk wrote 05/14/25, 07:18

    Created a revert of this change as If7d845d8be45e8fcc13e275fe0ebcaf457077d00