Review main Merged

71804[BUGFIX] Properly return path relative to public dir in FilePathSanitizer

Florian Rival CR +2 V +2 Normal +118 −53 updated 10/26/21, 11:51

Commit message

The assumption for FilePathSanitizer::sanitize is to return file names
relative to the public directory of TYPO3.

Therefore, when making a given absolute file path relative
with PathUtility::getPublicResourceWebPath, we must ensure to set the
second argument to false to avoid adding the current site path
to the relative path, but just directly return the relative path.

This bug was not covered by the test, because on CLI this API
NEVER appends the current site path. Therefore the test is now adapted
to simulate a frontend web request.

Also streamline usage of Environment API in tests to clarify intent.

Review

  • Code review CR +2 Done
    • Helmut Hummel +2
    • Simon Gilli +1
    • Robert Kärner +1
  • Verified V +2 Done
    • Helmut Hummel +2
    • Simon Gilli +1
    • Robert Kärner +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 1214

  1. Florian Rival uploaded patch set 1 10/15/21, 10:58

  2. core-ci voted on patch set 1 V -1 10/15/21, 11:07 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/18165

  3. Simon Gilli commented on patch set 1 CR -1 10/15/21, 11:46

    Thanks for your patch. The correct fix for this issue is here https://review.typo3.org/c/Packages/TYPO3.CMS/+/71806
  4. Helmut Hummel commented on patch set 1 CR -1 10/15/21, 11:47

    FilePathSanitizer.php:122

    good job in identifying the place where this needs to be fixed. The fix itself isn't valid like this unfortuately though
  5. Florian Rival commented on patch set 1 10/18/21, 07:58

    FilePathSanitizer.php:122 Reply

    Thanks for the feedback.. But why don't you keep the unit test, it seems that this case is missing.
  6. Stefan Bürk commented on patch set 1 CR -1 10/18/21, 13:17

    FilePathSanitizer.php:122 Reply

    Your added testcase is there in the patch linked by Simon and Helmut: publicAssetsInComposerModeResolvedCorrectly() => sanitizeCorrectlyResolvesPathsAndUrlsDataProvider() ``` 'legacy systems resolve private resources in public path' => [ 'EXT:frontend/Resources/Private/Templates/MainPage.html', 'typo3/sysext/frontend/Resources/Private/Templates/MainPage.html', ], ```
  7. Helmut Hummel commented on patch set 1 10/26/21, 09:35

    FilePathSanitizer.php:122 Reply

    > But why don't you keep the unit test, it seems that this case is missing. Yes good point. It was missing. Additionally the tests did not cover other important areas, that is why I completely refactored them to do so. AND: You deserve the credits for this fix as well. That is why I will push an update here with a commit that reference you as author and will abandon my change set. Thanks again for your contribution!
  8. Helmut Hummel uploaded patch set 2 10/26/21, 09:37

  9. Helmut Hummel voted on patch set 2 V +1 CR +1 10/26/21, 09:37

  10. Simon Gilli voted on patch set 2 V +1 CR +1 10/26/21, 09:42

  11. core-ci voted on patch set 2 V +1 10/26/21, 09:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/18566

  12. Robert Kärner voted on patch set 2 V +1 CR +1 10/26/21, 10:23

  13. Helmut Hummel voted on patch set 2 V +2 CR +2 10/26/21, 11:48

  14. Helmut Hummel merged patch set 3 10/26/21, 11:51