[node:summary] recieves unwanted inserted text from body format

Created on 3 May 2024, about 2 months ago
Updated 21 May 2024, 27 days ago

Problem/Motivation

I have an issue where elements (in my case, glossary definitions) are inserted into the contents of [node:summary] which I'm using for the meta description and og-description with the metatag module. This is a problem because these inserted elements are only intended as hidden tooltips in the content body (not the summary) ready to be revealed on the page when interacted with.

My understanding of the summary sub-field is that it is stored as plain text and in most cases (such as in views), it is rendered as such. I wasn't aware that generating the token would involve running the summary through all the text format filters for the body field itself, and it has caused this problem.

I understand that at one point there was a [node:teaser-raw] token, and that this would pose a security risk, and that other filtering is needed for when its absence would cause problems. But if I could define the format to be used, or if the raw value could be sanitized instead of the filtered value to create the token or an alternative token this would be so useful.

As it stands I'm dreading having to abandon the summary sub-field, and replace all its uses on our rather large site with a separate field, or to rewrite my tooltips to try and avoid this which would I need to balance against impacting accessibility on the page itself.

I'd love if there was a proper solution, but also if there are any known workarounds for this kind of problem I'd really appreciate it... like perhaps I should use a twig solution instead?

Steps to reproduce

  1. Use any text filter which modifies the content of the body field.
  2. Use [node:summary] as the meta description.
  3. Observe that the modifications have been applied to the summary.

Proposed resolution

Provide a sanitized pre-filtered token for [node:summary] like [node:summary:plain] or even [node:summary:0]

πŸ’¬ Support request
Status

Fixed

Version

1.14

Component

Code

Created by

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

Comments & Activities

  • Issue created by @jacobupal
  • Status changed to Fixed about 1 month ago
  • πŸ‡¨πŸ‡­Switzerland Berdir Switzerland

    [node:summary] is provided by the core node module, not token.module, and it essentially follows the same logic as the summary or trimmed formatter. If that behaviour is not what you want, then I would suggest you implement your own token. Until the text with summary field type is deprecated/removed from core, it's unlikely that this behavior will chnage.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024