evolvingweb / sitediff

SiteDiff makes it easy to see differences between two versions of a website.
http://sitediff.io
GNU General Public License v2.0
229 stars 48 forks source link

Ignore "itok" for image style URIs in Drupal preset #162

Closed jigarius closed 1 year ago

jigarius commented 1 year ago

The problem

Drupal adds tokens like ?itok=X to image styles. For example:

<picture>
  <source srcset="/sites/default/files/styles/STYLE/public/slides/2020-10/foo.jpg?itok=VzxcQ5P3" media="(max-width: 1280px)"/>
  <img alt="California, 12' x 7', profil daluminium Noir, verre Clair" src="/sites/default/files/styles/STYLE/public/slides/2020-10/foo.jpg?itok=VzxcQ5P3" width="1240" height="729"/>
</picture>

This results in many false positives.

jigarius commented 1 year ago

I haven't done much research, but I'm just sharing the quick solution that worked for me.

sanitization:
  - title: Ignore itok query parameter from image style URIs
    pattern: \?itok=[^"]+
    substitute: ?itok=__rand__
    selector: source,img
kdborg commented 1 year ago

I've updated the Drupal preset to handle this and other newer Drupal hashes.