Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cspiker created an issue. See original summary.

cspiker’s picture

Status: Active » Needs review
FileSize
2.46 KB
Liam Morland’s picture

Status: Needs review » Needs work

Thanks for the patch. There needs to be input validation before file_validate_image_resolution() is called.

cspiker’s picture

Status: Needs work » Needs review
FileSize
3.01 KB
2.6 KB

New patch against latest dev release with an added regex check of the validation rule format.

I don't believe that any input validation needs to be done on the uploaded file prior to calling file_validate_image_resolution(), since that function appears to do all the necessary validation itself (input is a file, file is uploaded, upload is an image, image has valid resolution).

Liam Morland’s picture

Status: Needs review » Needs work

Thanks for the patch. The variable $errs is assigned, but not used. Is something missing or changed incompletely?

james.williams’s picture

Status: Needs work » Needs review
FileSize
2.87 KB
3.75 KB

This patch addresses Liam's comment, but also adds a standalone 'valid image' rule to catch files that aren't even recognised as valid images. Core's file_validate_image_resolution() accepts files that cannot be processed as images (e.g. invalid/zero-byte files, or text files renamed to have .jpg file extensions, etc), even if dimension parameters have been set on the other rules. That may be desirable in some cases (even core allows for files like that, perhaps in case the supposedly-invalid images are actually permissible) - but that's exactly where this module comes in, to allow an admin to configure the rules.

Liam Morland’s picture

Thanks for the patch.

Please check the coding standards. This patch adds two lines that are too long.

It would be great to have some tests for this.

james.williams’s picture

Issue tags: +Needs tests

Sorry, which lines are too long? If you mean those containing the calls to t(), I don't think those would be correct to shorten, unless you can refer me to something saying otherwise please?

Liam Morland’s picture

If you click on the test results link above you can see the report:

1035 Line exceeds 80 characters; contains 81 characters
1054 Line exceeds 80 characters; contains 81 characters

It is best to learn how to use phpcs and phpcbf to find and fix coding standards issues.

james.williams’s picture

Oh, sorry - I see them! I don't think those lines (comments) are even needed anyway, so here's a patch without them.