Review main Merged

86873[TASK] Streamline MimeTypeValidator option handling in FileUpload

Torben Hansen CR +2 V +2 Normal +222 −17 updated 11/04/24, 14:26

Commit message

With #103511, the `FileUpload` attribute has been introduced to allow
file upload in extbase. For the `FileSize` and `ImageDimensions`
validators, it is possible to provide all possible validator options
via configuration. For the `MimeTypeValidator`, this is however not
possible and the validator is always initialized with the
`allowedMimeTypes` configuration only.

With this change, the `FileUpload` attribute has been extended to
support the new `mimeType` configuration, which allows to define
all possible options of the `MimeTypeValidator` (`allowedMimeTypes`,
`ignoreFileExtensionCheck`, `notAllowedMessage`,
`invalidExtensionMessage`).

The `allowedMimeTypes` configuration in the `FileUpload` attribute
is kept to ensure backwards compatibility for users already using
this configuration.

Review

  • Code review CR +2 Done
    • Garvin Hicking +2
    • Jörg Hofrichter +1
    • Benni Mack +1
  • Verified V +2 Done
    • Garvin Hicking +2
    • Jörg Hofrichter +1
    • core-ci +1 CI

Issues 2

Files 11

Review log 1925

  1. Torben Hansen uploaded patch set 1 11/02/24, 12:49

  2. core-ci voted on patch set 1 V -1 11/02/24, 12:56 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68977

  3. Torben Hansen uploaded patch set 2 V -1 11/02/24, 12:58

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

  5. Garvin Hicking commented on patch set 2 11/02/24, 17:16

    Important-105532-StreamlineMimeTypeValidatorOptionHandlingInFileUpload.rst:6

    Please also adopt the original feature rst with this configuration detail

    Important-105532-StreamlineMimeTypeValidatorOptionHandlingInFileUpload.rst:24

    How should we proceed with the "old" key? Maybe something like: For now, the shorthand notation of only specifying "allowedMimeTypes" remains available, too. Only the long notation will be utilized, if both keys are present.

    Important-105532-StreamlineMimeTypeValidatorOptionHandlingInFileUpload.rst:48

    Add in here the other mimeTyeeValidstor options as an example, to showcase the benefit of the migration instead of using the same festure?

    PropertyTest.php:379

    We should add test cases here utilizing the other config keys here? (enshuring that these work are not in the scope of these tests, just the availibility of the other keys)
  6. Jörg Hofrichter commented on patch set 2 CR +1 V +1 11/02/24, 21:24

    Functionally wise, the change works for me (applied this patch as well as patch 86874 and successfully tested setting "notAllowedMessage"). Regarding further improvements, I refer to the comments of Garvin Hicking.
  7. Torben Hansen uploaded patch set 3 CR +1 V +1 11/03/24, 06:27

  8. Torben Hansen commented on patch set 3 11/03/24, 06:28

    Important-105532-StreamlineMimeTypeValidatorOptionHandlingInFileUpload.rst:6 Reply

    Done

    Important-105532-StreamlineMimeTypeValidatorOptionHandlingInFileUpload.rst:24 Reply

    Done

    Important-105532-StreamlineMimeTypeValidatorOptionHandlingInFileUpload.rst:48 Reply

    The before and after example should use the same options to avoid confusion. I added an additional exampe at the end of the RST, which shows how to use validator options.

    PropertyTest.php:379 Reply

    The tests there only assure, that the class schema correctly retrieves the `FileUpload` configuration array. Array subkeys are not scope of the test and in terms of the `validation` key, basically all given subkeys are accepted.
  9. core-ci voted on patch set 3 V +1 11/03/24, 06:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/68995

  10. Garvin Hicking commented on patch set 3 11/03/24, 09:14

    Thanks Torben, that all works our for me and the added tests ensure the behavior that was important to me!

    Important-105532-StreamlineMimeTypeValidatorOptionHandlingInFileUpload.rst:65

    Following your previous advise I'd set this to false so that people won't copy&paste this as a security issue? :)
  11. Benni Mack commented on patch set 3 11/04/24, 09:01

    please merge the Important.RST with the existing feature 13.3 RST
  12. Garvin Hicking uploaded patch set 4 V +1 11/04/24, 09:11

    ReST changes positive test
  13. Garvin Hicking commented on patch set 4 11/04/24, 09:14

    I've reworked this patch slightly: * Added more info on the used validators * Notice about shorthand usage * Use all configuration options in the example * Added two positive tests that allow uploading a text/plain file

    Important-105532-StreamlineMimeTypeValidatorOptionHandlingInFileUpload.rst:65 Reply

    Done
  14. core-ci voted on patch set 4 V +1 11/04/24, 09:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69020

  15. Garvin Hicking commented on patch set 4 CR -1 11/04/24, 09:28

    on it
  16. Garvin Hicking uploaded patch set 5 CR -1 V +1 11/04/24, 09:41

    Unify ReST files into one
  17. Garvin Hicking voted on patch set 5 CR +1 V +1 11/04/24, 09:42

  18. core-ci voted on patch set 5 V +1 11/04/24, 09:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69024

  19. Garvin Hicking commented on patch set 6 CR +1 V +1 11/04/24, 10:01

    Published edit on patch set 5.
  20. core-ci voted on patch set 6 V +1 11/04/24, 10:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/69026

  21. Jörg Hofrichter commented on patch set 6 CR +1 V +1 11/04/24, 12:22

    Successfully verified patchset 6, setting the notAllowedMessage option to a custom message
  22. Garvin Hicking voted on patch set 6 CR +1 V +1 11/04/24, 13:26

  23. Benni Mack voted on patch set 6 CR +1 11/04/24, 13:42

  24. Garvin Hicking voted on patch set 6 CR +2 V +2 11/04/24, 13:43

  25. Garvin Hicking merged patch set 7 11/04/24, 14:26