-
-
Notifications
You must be signed in to change notification settings - Fork 88
FileUpload: fix getters calls on empty FileUpload #195
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
Closed
Conversation
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
6ee31b8 to
4f4a403
Compare
a8895b6 to
9409a5f
Compare
a85dc37 to
12e2e54
Compare
2a0c595 to
4ca7b03
Compare
da24b94 to
540335c
Compare
e7c7e2d to
bf945f3
Compare
9a14e6e to
a20fb8f
Compare
55488bd to
2042d2e
Compare
4960652 to
5e67add
Compare
dg
pushed a commit
that referenced
this pull request
Nov 4, 2024
Member
|
fixed |
dg
pushed a commit
that referenced
this pull request
Nov 4, 2024
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.
This happened to me recently: I forgot to mark form item with file upload as mandatory, so users were able to send form without any file. But on backend I have complex system of validators, which want to validate name, size etc. Validators are build using composition and each of them do just one thing (for example one of them just calls
getName(newlygetSanitizedName/getUntrustedName) on receivedFileUploadand checks its name...). It's not really handy to repeat in each of them condition with$file->isOk()... But if I didn't have it there, it would crash on the error:Return value of Nette\Http\FileUpload::getName() must be of the type string, null returned(in PHP 7.3), because properties don't have default values andnullis not compatible with typehintstring...I believe that getters should be callable without an error even on empty file upload, to make behavior of our
FileUploadmore predictable and consistent.I tried to add failing test and fix it.
I hope it's ok for you, just let me know if some changes needed.
Thanks.