Skip to content

Regular expressions: PCRE errors taken for no match, invalid patterns only detected with the first value #408

Closed

Description

@njoubert-cleverage

The regular expressions of the options are neither validated nor checked for PCRE errors:

  • PCRE errors taken for "no match": invalid UTF-8 with the u modifier, or the backtracking limit, makes preg_match() return false and preg_filter() / preg_replace() return null, without warning. preg_match then outputs an empty array, preg_filter outputs null as for "no match", slugify outputs an empty slug, and the conditions (match_regexp, not_match_regexp of filter, column_aggregator, array_filter, unset) exclude the input with both options.
  • Invalid patterns detected with the first value only: a pattern that does not compile (e.g. /(a/) emits a PHP warning with the first value (an exception in debug mode only). Otherwise it behaves as "no match": match_regexp and not_match_regexp then both exclude every input.

Fix: validate the patterns when the options are resolved (InvalidOptionsException), and check preg_last_error() after a failed call (UnexpectedValueException with the PCRE error message).

Found during the audit v3 (audit-v3-angles.md #196).

Activity

  1. added 2 commits that reference this issue on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions