Skip to content

Commit 406a29b

Browse files
committed
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.
1 parent e7a4152 commit 406a29b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

roundup/cgi/form_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ def parse(self, create=0, num_re=re.compile('^\d+$')):
469469
# Multilink.from_raw.
470470
value.sort(key=int)
471471

472-
elif value == '':
472+
elif value == '' or value == b'':
473473
# other types should be None'd if there's no value
474474
value = None
475475
else:

0 commit comments

Comments
 (0)