Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clobbering of the upload size validation #10058

Closed
nfauchelle opened this issue Aug 17, 2021 · 2 comments
Closed

Fix clobbering of the upload size validation #10058

nfauchelle opened this issue Aug 17, 2021 · 2 comments

Comments

@nfauchelle
Copy link
Contributor

nfauchelle commented Aug 17, 2021

Affected Version

4.8

Description

yml config for the max size of uploads is getting over-written by a single '*' rule which is done in.

src/Forms/UploadReceiver.php -> constructUploadReceiver() method.

We simply need to remove the comment and 3 lines that set the size from that method.

If you review SilverStripe\Assets\Upload_Validator and check the getAllowedMaxFileSize method, you'll see the sizing will be populated (if it hasn't been done before).

yml config expected to work.

SilverStripe\Assets\Upload_Validator:
  default_max_file_size:
    '[image]': '2m'
    '*' : '1m'

Steps to Reproduce

  • Setup a new SilverStripe site.
  • Add the config above to the yml file.
  • Set your PHP to allow max post / max upload size of 10mb.
  • Add the above config to your sites yml file and flush.
  • In the CMS you'll be able to upload a 5MB file, when you shouldn't.

When you define max sizing in the yml file, it gets over-ridden with the CMS UploadField.

Here is the change here, nfauchelle@564ecbc
I don't have permission to submit a pull request.

PRs

@michalkleiner
Copy link
Contributor

@nfauchelle thanks for reporting and the reproduction steps.

With PRs, generally, you'd fork the framework repo, fix the issue in a new branch off the latest minor version branch, i.e. 4.8 at this point in time, and then you can submit a cross-repo PR against that minor version branch from your fix branch.

@emteknetnz
Copy link
Member

emteknetnz commented Jan 8, 2024

Linked PRs have been merged, they will be released in 5.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants