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

Handle multipart form upload with empty file as BadPart #8882

Merged
merged 9 commits into from Dec 18, 2018

Conversation

Projects
None yet
3 participants
@mkurz
Copy link
Member

mkurz commented Dec 14, 2018

#8880 was for empty filenames, this is for empty files.

mkurz added some commits Dec 14, 2018

@mkurz mkurz requested a review from marcospereira Dec 14, 2018

@mkurz mkurz added this to the Play 2.7.0 milestone Dec 14, 2018

mkurz added some commits Dec 17, 2018

@mkurz

This comment has been minimized.

Copy link
Member Author

mkurz commented Dec 17, 2018

@marcospereira Please have a look again. Now an empty file will not even be created anymore. I added a checkEmptyBody method which finds out if the body of a multipart element is empty and calls corresponding methods.

mkurz added some commits Dec 17, 2018

@marcospereira
Copy link
Member

marcospereira left a comment

LGTM.

Thanks, @mkurz.

@@ -340,11 +340,11 @@ object Multipart {
def parseHeader(input: ByteString, headerStart: Int, memoryBufferSize: Int): StateResult = {
input.indexOfSlice(crlfcrlf, headerStart) match {
case -1 if input.length - headerStart >= maxHeaderSize =>
bufferExceeded("Header length exceeded buffer size of " + memoryBufferSize)
bufferExceeded("Header length exceeded maximum header size of " + maxHeaderSize)

This comment has been minimized.

@marcospereira

marcospereira Dec 18, 2018

Member

❤️

@mkurz mkurz merged commit f031b20 into playframework:master Dec 18, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
typesafe-cla-validator All users have signed the CLA
Details

@mkurz mkurz deleted the mkurz:multipartFixZeroFilesize branch Dec 18, 2018

@mkurz

This comment has been minimized.

Copy link
Member Author

mkurz commented Jan 9, 2019

This still needs to be backported to 2.7.x, seems like it was overlooked.

renatocaval added a commit that referenced this pull request Jan 10, 2019

Handle multipart form upload with empty file as BadPart (#8882)
* Handle multipart form upload with empty file as BadPart

* Fix failing test because empty file isn't available anymore

* Better error log

* Revert original fix

* Handle multipart form upload with empty file as BadPart

* More test cases

* Correct error message

* Migration notes + mention behaviour in upload docs

* One more test (file with newline only)
@renatocaval

This comment has been minimized.

Copy link
Contributor

renatocaval commented Jan 10, 2019

Backported to 2.7.x (cc9783d)

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