Merge conflict Gerrit cannot merge this change. It needs a rebase onto main.

Review main Ready for review Quiet

96201[FEATURE] Introduce upload constraints for file uploads

Sebastian Michaelsen CR 0 V 0 Expert +1432 −41 updated 09/30/26, 09:00

Commit message

The rules deciding whether a file may be uploaded were
hard-coded and implemented twice: as client-side hint for the
drag uploader and as server-side check in ResourceStorage.
Extensions could not add rules of their own.

Services implementing UploadConstraintInterface are now
collected as "file.upload_constraint" and run by
UploadConstraintRegistry: describe() provides the client
hints, validate() checks every upload in ResourceStorage.
Rejected uploads throw UploadRejectedException.

The PHP upload limit and the file deny pattern are ported to
constraints. GeneralUtility::getMaxUploadFileSize() is
deprecated in favour of the registry.

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 2
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/01/96201/2 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/01/96201/2 && git cherry-pick FETCH_HEAD

Review

  • Code review CR 0 Needs a vote
  • Verified V 0 Needs a vote
    • core-ci +1 CI

Issues 2

Files 36

Show 16 more files

Review log 68

  1. Sebastian Michaelsen uploaded patch set 1 09/30/26, 06:18

  2. core-ci voted on patch set 1 V +1 09/30/26, 06:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/109577

  3. Sebastian Michaelsen marked it ready for review 09/30/26, 08:17

  4. Benni Mack commented on patch set 1 CR -1 09/30/26, 08:26

    ResourceStorage.php:1036

    is that right? If so, this means, if I use the frontend for uploading things, and I'm logged in, it would behave differently? This should be clarified, Ideally the UploadConstraint is actually handed into the ResourceStorage?
  5. Sebastian Michaelsen marked it work in progress 09/30/26, 08:42

  6. Sebastian Michaelsen uploaded patch set 2 CR -1 V +1 09/30/26, 08:51

  7. core-ci voted on patch set 2 V +1 09/30/26, 08:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/109599

  8. Sebastian Michaelsen commented on patch set 2 09/30/26, 09:00

    This change is ready for review.

    ResourceStorage.php:1036 Reply

    Good catch. That was unintentional. In patchset #2 the backend user is now set as a property of the ResourceStorage only if we're in a backend request. I did not pass the UploadContext (I assume you meant that), because the ResourceStorage already knows the storage and folder and the user binding of the storage fits nicely into StoragePermissionsAspect. If you really want to pass the UploadContext into ResourceStorage, I can build it that way as well.