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.

Issue fork token-3137689

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

manuel.adan created an issue. See original summary.

manuel.adan’s picture

Assigned: manuel.adan » Unassigned
Status: Active » Needs review
StatusFileSize
new1.02 KB
sascha_meissner’s picture

Title: Image URL tokens are HTML escaped » Adjusted patch to work with 8.x-1.11
Version: 8.x-1.x-dev » 8.x-1.11
StatusFileSize
new1.04 KB

Adjusted patch #2 to work with 8.x-1.11

berdir’s picture

Title: Adjusted patch to work with 8.x-1.11 » Image URL tokens are HTML escaped
Version: 8.x-1.11 » 8.x-1.x-dev
Manoj Raj.R’s picture

#2 #3 both looks good for me.

heni_deepak’s picture

#3 looks good to me. RTBC ?
test patches also pass 8.1 and in D9.5

metalbote’s picture

Simple reroll

sascha_meissner’s picture

Created a MR for convenience ;-)