Problem/Motivation

The $text parameter of Token::replace() is documented as follows:

The caller is responsible for calling \Drupal\Component\Utility\Html::escape() in case the $text was plain text.

There are instances in core where this does not happen, which means that plain text that resembles HTML would be corrupted. For example an Email action with subject What do you think of the <blink> tag? would get corrupted to What do you think of the tag?.

When fixing this bug, we need to consider that sites might have observed this bug and compensated for it, by setting their subject to What do you think of the &lt;blink&gt; tag?. If we fix this bug, these sites would start sending emails without decoding those escaped entities. However it's hard to see how to fix the bug without this problem, so perhaps we just have to document it clearly in the release notes.

This issue was split off from #2580723: Fix token system confusion, with new function Token::replacePlain(), see lengthy discussion there for further background.

Proposed resolution

Use the Token::replacePlain() method.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#2 token-corrupt.3264453-2.patch6.31 KBadamps

Comments

AdamPS created an issue. See original summary.

adamps’s picture

Status: Active » Needs review
StatusFileSize
new6.31 KB

This patch will apply after #2580723: Fix token system confusion, with new function Token::replacePlain() is fixed. It probably makes sense to postpone this one until after the other.

Status: Needs review » Needs work

The last submitted patch, 2: token-corrupt.3264453-2.patch, failed testing. View results

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

adamps’s picture

Issue summary: View changes
adamps’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs tests

Thank you for reporting.

As a bug will also need a test case showing this issue.

adamps’s picture

As a bug will also need a test case showing this issue.

Sure however before spending time on that please can we get agreement that this would be accepted and committed?

larowlan’s picture

I think a release manager would be the best person to answer the question in #9 as (per the issue summary) there's a possible impact on existing sites here.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.