Fix false "invalid file size" error on boards with unlimited attachment size - #17
Open
ECYaz wants to merge 1 commit into
Open
Fix false "invalid file size" error on boards with unlimited attachment size#17ECYaz wants to merge 1 commit into
ECYaz wants to merge 1 commit into
Conversation
The custom badge upload compared the file size against $config['max_filesize'] directly. In phpBB a max_filesize of 0 means "no limit", so on boards configured that way the check `$max_size < $file_upload['size']` was always true and every upload was rejected with "The image you uploaded has an invalid file size." (regardless of file type). Cast the setting to int and only enforce it when it is greater than 0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Uploading a custom verification badge fails with "The image you uploaded has an invalid file size." on some boards, for every file and file type.
In
acp/settings_module.php, the size check compares the upload against$config['max_filesize']directly:In phpBB, an attachment
max_filesizeof0means "no limit" (that's how the core attachment settings treat it). On any board configured that way,$max_size < $file_upload['size']is0 < <size>, which is always true, so the size check rejects every upload before the file-type check is even reached. Boards left on the default limit (262144) with a small badge are unaffected — which is why it only happens on some installs, and why it looks like it applies to all file types.Fix
Cast the setting to
intand only enforce the maximum when it is greater than zero:Behaviour before/after (size gate only):
max_filesize= 0), small badgeThe change only affects the
max_filesize == 0case; a genuinely oversized upload against a set limit is still rejected.Scoped to this one issue — no other changes.