Review main Merged

94657[BUGFIX] Prevent PHP warning on invalid regex in replacement stdWrap

Georg Ringer CR +2 V +2 Easy +19 −0 updated 08/12/26, 13:59

Commit message

When useRegExp is enabled and "search" is not a compilable pattern
(e.g. a single backslash), preg_replace() emitted a warning and
returned null, silently wiping the content. Validate the pattern up
front and skip such invalid actions, keeping the content untouched.

Review

  • Code review CR +2 Done
    • Georg Ringer +2
    • Garvin Hicking +1
    • Benni Mack +1
  • Verified V +2 Done
    • Georg Ringer +2
    • Oliver Klee +1
    • Garvin Hicking +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 910

  1. Georg Ringer uploaded patch set 1 07/01/26, 19:14

  2. Georg Ringer commented on patch set 1 07/01/26, 19:14

    This change is ready for review.
  3. core-ci voted on patch set 1 V +1 07/01/26, 19:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/104206

  4. Garvin Hicking commented on patch set 1 07/03/26, 17:12

    ContentObjectRenderer.php:1572

    Wbat about the elseif below, could happen there too?
  5. Georg Ringer commented on patch set 1 08/05/26, 10:22

    ContentObjectRenderer.php:1572 Reply

    the elseif ($useOptionSplitReplace) branch is safe: unlike the regex branch, it doesn't take a user-supplied pattern. It builds the pattern itself via preg_quote($search, '#') with fixed # delimiters, so the result is always compilable regardless of input (empty string, a lone backslash, #, null byte, …). The invalid-pattern problem only exists in the useRegExp branch, where the user provides the delimiters. So no additional guard is needed there.
  6. Oliver Klee voted on patch set 1 V +1 08/05/26, 10:35

  7. Garvin Hicking commented on patch set 1 CR +1 V +1 08/05/26, 20:08

    ContentObjectRenderer.php:1572 Reply

    Done
  8. Benni Mack voted on patch set 1 CR +1 V +1 08/12/26, 11:19

  9. Georg Ringer voted on patch set 1 CR +2 V +2 08/12/26, 13:59

  10. Georg Ringer merged patch set 2 08/12/26, 13:59