aelvan / Imager-Craft

This plugin has been DEPRECATED. Check out Imager X instead.
MIT License
342 stars 69 forks source link

Watermark Position Filename Collision #244

Closed rungta closed 5 years ago

rungta commented 5 years ago

https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/helpers/ImagerHelpers.php#L360

We allow clients to control the watermark position on their images (left vs right). This results in transform configs like:

{# Left #}
{ watermark: { … position: { bottom: 30, left: 30 }}}

{# Right #}
{ watermark: { … position: { bottom: 30, right: 30 }}}

However, since only the first ten characters of the watermark config hash are being considered, both left and right options are resulting in the same filename …_WM_00266a72f0.jpg, leading to a collision.

rungta commented 5 years ago

Actually, on closer inspection, the entire hash was turning out to be the same. That is because the string being hashed also ends up being the same for both the left and right position values, due to the is_array($v) ? implode('-', $v) condition, where the keys are not factored into the hash.

https://github.com/aelvan/Imager-Craft/blob/f7e80a3cd8c3b3a29fd8ca8961bf452727d52a32/src/helpers/ImagerHelpers.php#L357

aelvan commented 5 years ago

This has been fixed for the next release.