Attempting to upload a .zip file to a webform where .zip was checked, as well as manually entered as an additional file extension, we get following error, generated by core's file_validate_extensions() due to a bad $extensions argument passed by file_save_upload().
"The specified file foo.zip could not be uploaded. Only files with the following extensions are allowed: jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp."
This is because we don't pass the component's configured list of file extensions to file_save_upload().
Let's do that :).
I tested this patch and it accepts checkbox configured extensions as we as manually specified ones, while still forbidding non-specified extensions, like .exe.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | webform-992130-file-extensions-6.patch | 1.18 KB | effulgentsia |
| #1 | webform_file_validate-d7.patch | 831 bytes | quicksketch |
| webform-file-extensions.diff | 1.51 KB | ezra-g |
Comments
Comment #1
quicksketchWe can simplify this patch quite a bit because $component['extra']['filtering']['types'] always exists and already contains the merged list of extensions. There's no need to merge in 'addextensions'. I've committed this patch which gets file uploads working.
Comment #2
phishyman2 commentedAre there a link to instructions on how to install a patch? I am currently on a shared hosting plan.
Thanks in advance.
Comment #3
quicksketchThis is included in the 3.6 version released yesterday, just upgrade the module like you would normally (don't forget to run update.php).
Comment #4
phishyman2 commentedThanks you very much for your response. Sorry for the bumping earlier.
Comment #6
effulgentsia commented#1 causes 'jpeg' to fail. Here's a quick fix. This also includes a comment unrelated to this fix, but that helps explain why we're setting 'file_validate_extensions' the way we are, despite also doing our own validation.
Comment #7
David_Rothstein commentedI tested this patch and confirmed that it works ('jpeg' is now allowed whenever 'jpg' is), and the comment makes sense too.
Comment #8
quicksketchThanks guys, committed.