Generated with the help of an LLM.

Problem/Motivation

Since #3491615 (2.3.3 and 3.0.0-beta1), text like [widget:name attr="a|b"] hangs the request. The quote-aware split returns a single part, equal to the whole match. It looks like a token, so TokenOrTokensPreAlter::tokensPreAlter() calls the token service on the same text, which fires hook_tokens_pre_alter() again, without end.

We hit it with shortcodes in node bodies. Article pages ran for 60 seconds and returned 503. 2.3.2 is not affected.

Steps to reproduce

\Drupal::token()->replace('[widget:x attr="a|b"]');

On 2.3.3 and 3.0.0-beta1 this runs until memory is exhausted. On 2.3.2 it returns the text unchanged.

Proposed resolution

Skip the match when the split gives fewer than two parts. MR with a kernel test follows.

Issue fork token_or-3633480

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

sjpagan created an issue. See original summary.

sjpagan’s picture

Status: Active » Needs review

pianomansam made their first commit to this issue’s fork.

  • soltz committed 5555e629 on 2.x
    fix: #3633480 Infinite recursion when every pipe in a bracketed token is...

  • soltz committed 9cb1533f on 3.x
    fix: #3633480 Infinite recursion when every pipe in a bracketed token is...
pianomansam’s picture

Status: Needs review » Fixed

Thanks @sjpagan. I added a few more tests and merge in to both branches.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.