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
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:
- 3633480-infinite-recursion-when
changes, plain diff MR !28
- 3633480-2.x
changes, plain diff MR !29
Comments
Comment #4
sjpagan commentedComment #8
pianomansam commentedThanks @sjpagan. I added a few more tests and merge in to both branches.