Review main Merged

85485[FEATURE] Provide validators for PSR-7 UploadedFile objects in Extbase

Torben Hansen CR +2 V +2 Expert +1227 −1 updated 08/06/24, 12:01

Commit message

When working with PSR-7 `UploadedFile` objects, it is crucial to validate
the uploaded file against common validation rules.

This change introduces 4 new validators to Extbase for validating PSR-7
`UploadedFile` objects or an `ObjectStorage` containing
`UploadedFile` objects:

- FileNameValidator: Prevents uploading of files with PHP executable
  extensions.
- FileSizeValidator: Validates file size against given minimum and
  maximum limits.
- MimeTypeValidator: Validates file MIME types and optionally checks
  file extensions.
- ImageDimensionsValidator: Validates image dimensions with options
  for width, height, and range limits.

Extension authors can use the new validators to handle file uploads
in extbase context (e.g. `UploadedFile` property in DTO).

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Daniel Goerz +1
    • Christian Kuhn +1
  • Verified V +2 Done
    • Benni Mack +2
    • Christian Kuhn +1
    • core-ci +1 CI

Issues 1

Files 14

Review log 1927

Show 12 earlier messages
  1. Torben Hansen uploaded patch set 1 08/02/24, 09:43

  2. core-ci voted on patch set 1 V +1 08/02/24, 09:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/62711

  1. Mathias Brodala commented on patch set 1 08/02/24, 10:12

    DenyPhpUploadValidator.php:27

    This should also be "FileNameValidator" since it better describes what it does. The current name makes many assumptions and is too specific.
  2. Torben Hansen uploaded patch set 2 V +1 08/02/24, 12:58

  3. Torben Hansen commented on patch set 2 08/02/24, 12:59

    DenyPhpUploadValidator.php:27 Reply

    Done
  4. core-ci voted on patch set 2 V +1 08/02/24, 13:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/62729

  5. Mathias Brodala commented on patch set 2 08/02/24, 13:08

    DenyPhpUploadValidatorTest.php:25

    Can you also update this one to match its SUT? ;-)
  6. Torben Hansen uploaded patch set 3 V +1 08/02/24, 17:43

  7. Torben Hansen commented on patch set 2 08/02/24, 17:44

    DenyPhpUploadValidatorTest.php:25 Reply

    Done
  8. core-ci voted on patch set 3 V +1 08/02/24, 17:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/62762

  9. Torben Hansen uploaded patch set 4 V +1 08/04/24, 06:41

  10. core-ci voted on patch set 4 V +1 08/04/24, 06:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/62820

  11. Torben Hansen marked it work in progress 08/04/24, 09:24

  12. Torben Hansen uploaded patch set 5 V +1 08/04/24, 11:01

  13. Torben Hansen marked it ready for review 08/04/24, 11:02

  14. core-ci voted on patch set 5 V -1 08/04/24, 11:08 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/62826

  15. Torben Hansen uploaded patch set 6 V -1 08/04/24, 11:21

  16. core-ci voted on patch set 6 V +1 08/04/24, 11:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/62827

  17. Daniel Goerz commented on patch set 7 V +1 08/06/24, 09:14

    Published edit on patch set 6.
  18. core-ci voted on patch set 7 V +1 08/06/24, 09:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/62887

  19. Daniel Goerz commented on patch set 7 CR +1 08/06/24, 09:21

    While I'd rather see the validators work for the PSR-7 interface I do not see a good way to make that work as the interface does not allow access to the file before it has been moved. Will also test the patch when I find the time ...
  20. Torben Hansen uploaded patch set 8 CR +1 V +1 08/06/24, 09:33

  21. core-ci voted on patch set 8 V +1 08/06/24, 09:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/62889

  22. Daniel Goerz voted on patch set 8 CR +1 08/06/24, 09:39

  23. Christian Kuhn voted on patch set 8 CR +1 V +1 08/06/24, 09:50

  24. Benni Mack voted on patch set 8 CR +2 V +2 08/06/24, 12:01

  25. Benni Mack merged patch set 9 08/06/24, 12:01