Pathologic breaks srcset when used with multipliers

Created on 14 April 2023, over 1 year ago
Updated 22 February 2024, 7 months ago

A site using repsonsive images (via the core "responsive_image" module) with multiplers is producing markup like this (via the core "media" module):

<source srcset="/sites/default/files/styles/ucbweb_media_width_400/public/stock-photos/CampanileWindow_1200_KeeganHouser.jpg?itok=tm8WkdEz 1x, /sites/default/files/styles/ucbweb_media_width_800/public/stock-photos/CampanileWindow_1200_KeeganHouser.jpg?itok=RvM2BU8N 2x" media="(min-width: 576px) and (max-width: 767px)" type="image/jpeg">

Notice how the "srcset" has two URLs with multipliers, joined by a comma.

After being processed by the Pathologic input filter, it looks like this:

<source srcset="http://ucbweb.lndo.site/sites/default/files/styles/ucbweb_media_width_400/public/stock-photos/CampanileWindow_1200_KeeganHouser.jpg?itok=tm8WkdEz%201x%2C%20/sites/default/files/styles/ucbweb_media_width_800/public/stock-photos/CampanileWindow_1200_KeeganHouser.jpg%3Fitok%3DRvM2BU8N%202x" media="(min-width: 576px) and (max-width: 767px)" type="image/jpeg">

It correctly put the full path on the first URL, but everything else after that got URL encoded, including the multipliers, spaces and comma - as if they were all part of the first URL.

The end result is a broken image!

If Pathologic is going to process "srcset", it should only modify the URLs, and not touch anything else in there.

πŸ› Bug report
Status

Needs work

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States dsnopek USA

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024