Alt text with comma adds extra, broken og:image

Created on 9 July 2023, over 1 year ago

Problem/Motivation

Conditions:

  • Image field that allows multiple images
  • The node itself has 3 images (just an example)
  • For the og:image meta tag, using the [node:field_report_photos] (just an example, note that I don't use a number to specify just one, but want all to show up in the meta tags
  • The alt text for at least one of them has a comma. In this example, Toronto, Canada.

The resulting HTML is this:

<meta property="og:image:url" content="https://example.com/sites/default/files/2023-07/IMG_9727.jpeg" />
<meta property="og:image:url" content="https://example.com/sites/default/files/2023-07/IMG_9729.jpeg" />
<meta property="og:image:url" content="https://example.comCanada&quot; /&gt;" />
<meta property="og:image:url" content="https://example.com/sites/default/files/2023-07/IMG_9728.jpeg" />

Note the third item is broken (and shouldn't even show up).

Steps to reproduce

See above.

Proposed resolution

Should the alt text be escaped?

Remaining tasks

Not sure.

User interface changes

None.

API changes

None probably.

Data model changes

None probably.

πŸ› Bug report
Status

Active

Version

2.0

Component

Open Graph

Created by

πŸ‡¨πŸ‡¦Canada sillygwailo Toronto, ON

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

Comments & Activities

  • Issue created by @sillygwailo
  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    For this scenario what you have to do is change the separator to something else instead of the default comma, then tags will output as expected.

  • I also stumbled upon this bug.

    image description – slogan with a reference to the image and page content containing a comma

    As a solution, I removed the comma, but now the alt text is not grammatically correct.

  • πŸ‡ΊπŸ‡ΈUnited States DamienMcKenna NH, USA

    Please try the new setting that lets you change the separator from a comma to something else, that should resolve the problem.

  • Thanks, that did the trick but wouldn't it still be better to not interpret this character in fields that do not allow multiple values?

    Or wouldn't it be better to replace the default , character with a less common unicode character such as 𒐫? Or will that introduce new problems on systems without unicode support?

Production build 0.71.5 2024