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.

Comments

quicksketch’s picture

Status: Needs review » Fixed
StatusFileSize
new831 bytes

We 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.

phishyman2’s picture

Are there a link to instructions on how to install a patch? I am currently on a shared hosting plan.

Thanks in advance.

quicksketch’s picture

This is included in the 3.6 version released yesterday, just upgrade the module like you would normally (don't forget to run update.php).

phishyman2’s picture

Thanks you very much for your response. Sorry for the bumping earlier.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

effulgentsia’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new1.18 KB

#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.

David_Rothstein’s picture

Status: Needs review » Reviewed & tested by the community

I tested this patch and confirmed that it works ('jpeg' is now allowed whenever 'jpg' is), and the comment makes sense too.

quicksketch’s picture

Status: Reviewed & tested by the community » Fixed

Thanks guys, committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.