Image URL tokens are HTML escaped

Created on 18 May 2020, over 4 years ago
Updated 4 November 2024, 3 months ago

Problem/Motivation

Using the image style URL token I'm getting values like this:

http://localhost/sites/default/files/styles/small_square/public/some/path/image.jpg?h=209f3b97&itok=p0RR9BOl

Note the "&" in the value that ends in a broken image when the URL is used as img src.

As far I can see, tokens are HTML escaped by core when the callback returns a string value rather than a MarkupInterface impl.

Proposed resolution

Return the image style URL token value enclosed in a Markup object instead as simple string to prevent being escaped and therefore return a malformed URL.

Remaining tasks

  • review
  • check for other potential similar cases
  • test

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

TBD.

🐛 Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

🇪🇸Spain manuel.adan 🌌

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024