Mercurial > p > roundup > code
diff roundup/cgi/form_parser.py @ 5522:c5c33e62da39
Fix absent file uploads with Python 3.
If a form has a file upload input control for a Link to a FileClass
class, but no file is uploaded, browsers submit this as an upload with
empty filename and file contents. This then goes through the Roundup
code:
# value might be a single file upload
if not getattr(value, 'filename', None):
value = value.value.strip()
which results in value holding those empty file contents.
With Python 2, the code
elif value == '':
# other types should be None'd if there's no value
value = None
then results in value being set to None, meaning no file node gets
created. With Python 3, however, value is b'' at this point and so
the code ends up creating a file node with empty content. Thus, this
patch fixes this by also checking for b'' there.
| author | Joseph Myers <jsm@polyomino.org.uk> |
|---|---|
| date | Sat, 01 Sep 2018 18:29:16 +0000 |
| parents | 3fa026621f69 |
| children | 936275dfe1fa |
line wrap: on
line diff
--- a/roundup/cgi/form_parser.py Thu Aug 30 00:26:13 2018 +0000 +++ b/roundup/cgi/form_parser.py Sat Sep 01 18:29:16 2018 +0000 @@ -469,7 +469,7 @@ # Multilink.from_raw. value.sort(key=int) - elif value == '': + elif value == '' or value == b'': # other types should be None'd if there's no value value = None else:
