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

V15: Client should validate maxFileSize and allowed/disallowed file types from server configuration #18163

Merged
merged 41 commits into from
Jan 30, 2025

Conversation

iOvergaard
Copy link
Contributor

@iOvergaard iOvergaard commented Jan 29, 2025

Description

Fail early if file upload exceeds certain parameters.

Changes

  • Implements the temporary file configuration endpoint with repository, store, and mock data
  • Adds validation for maxFileSize in bytes in the TemporaryFileManager to fail early for any field wanting to upload a temporary file (media picker, file upload, RTE, dropzone)
  • Adds validation for allowedUploadedFileExtensions and disallowedUploadedFileExtensions based on server settings to fail early for fields uploading temporary files
  • Adds a new utility function to format the "bytes" number to a human-readable number.

Caveats

  • When uploading a file in the media library dropzone, the client will still ask you to pick a media type even though the file might be invalid. There will be an upcoming pull request adding some validation to the dropzone itself to remedy some of this.

How to test

  1. Set the server configuration Runtime::MaxRequestLength to something like 51200 (50 MB) and try to upload an image larger than that. It should now warn you that the image is too large in the media picker, RTE, media library, etc, and it should NOT make a server request.
  2. Set the server configuration Content::DisallowedUploadedFileExtensions to something like ["exe"] and try to upload a .exe file, check that a warning is shown to the user and NO request is sent.
  3. Check that the opposite of the above is true, i.e., you can upload allowed files

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard
…mick the OpenAPI generator

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard
…property

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard
…cate upload status

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard
… able to show the progress in percent

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard
…re/temporary-file-configuration

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard
…ary-file-configuration

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard
…numberformat

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard
@leekelleher leekelleher self-requested a review January 29, 2025 16:13
iOvergaard and others added 2 commits January 30, 2025 08:56

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
…function.ts

Co-authored-by: Lee Kelleher <[email protected]>

Verified

This commit was signed with the committer’s verified signature.
iOvergaard Jacob Overgaard

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Copy link
Member

@leekelleher leekelleher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested out, working great! 🚀

@iOvergaard iOvergaard merged commit 22d974e into v15/dev Jan 30, 2025
29 checks passed
@iOvergaard iOvergaard deleted the v15/feature/temporary-file-configuration branch January 30, 2025 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants