You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Regular expressions: PCRE errors taken for no match, invalid patterns only detected with the first value #408
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
#408 - RegexTest: do not assert the end of the PHP warning, which dep…
Merge pull request #409 from cleverage/408