crop_file_url_alter parses a uri to check for a crop style and tries to do a Crop::findCrop(), but the findCrop doesn't work if, for example, the filename has a space in it because the alter hook receives an encoded URL, which won't match the URI in the database. Ex:

$file_uri = public://images/profile%20copy_0.jpg

vs

database = public://images/profile copy_0.jpg

so findCrop() returns empty and a hash is not applied.

The attached patch does a rawurldecode() on the parsed URI path which is sent to the entity query in findCrop() if there's a crop style. Is there potential for security issues with this approach?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

blake.thompson created an issue. See original summary.

blake.thompson’s picture

Status: Active » Needs review
weri’s picture

woprrr’s picture

Status: Needs review » Postponed (maintainer needs more info)
Related issues: +#2868339: Public folder check in crop_file_url_alter() is incorrect, does not work for responsive images

Hello all Sorry for the response delay !! Thank to your sugest patch. I have tested if Berdir patch on #2868339: Public folder check in crop_file_url_alter() is incorrect, does not work for responsive images fix this issue too and this is our case. Usage of "UrlHelper::parse()" to retreive parsed_uri take good results. Can you confirm me if berdir patch solve the problem ?

woprrr’s picture

Status: Postponed (maintainer needs more info) » Fixed
FileSize
37.02 KB
1.26 MB

I mark this issue as fixed because probably berdir issue solve your problems.

Look my test :

Status: Fixed » Closed (fixed)

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