Created
January 9, 2017 18:48
-
-
Save docapotamus/22040ea7791a9725bbbe36ef36a12179 to your computer and use it in GitHub Desktop.
FileField fails validation when empty (Flask-WTF 0.14)
This file contains 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
# Work successfully in my tests | |
resp = self.client.post( | |
url_for('posts.post'), | |
data={ | |
'body': 'Test', | |
'upload': '', | |
}, | |
follow_redirects=True | |
) | |
# However if I upload the code using multipart-form-data (taken from Firefox inspector `Params`, same issue in Chrome) | |
""" | |
Content-Type: multipart/form-data; boundary=---------------------------191598866112415400995302957 | |
Content-Length: 651 | |
-----------------------------191598866112415400995302957 | |
Content-Disposition: form-data; name="body" | |
Test | |
-----------------------------191598866112415400995302957 | |
Content-Disposition: form-data; name="csrf_token" | |
IjY4YTZmYjNmNWM4MWJlNmVjMjc3Y2Y4YjBiMTM1Nzk3YTdhMGZkNjci.C1VoNg.8Pg2PvN8N00Phc527XVBXjAn9rs | |
-----------------------------191598866112415400995302957 | |
Content-Disposition: form-data; name="permission" | |
0 | |
-----------------------------191598866112415400995302957 | |
Content-Disposition: form-data; name="upload"; filename="" | |
Content-Type: application/octet-stream | |
-----------------------------191598866112415400995302957-- | |
""" | |
# This has only started happening since since Flask 0.14 upgrade |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment