PHP 7.3.13

I switched from PHP 7.2.26 to PHP 7.3.13 and that broke my WordPress blog. The problem was Aram Kocharyan’s Crayon Syntax Highlighter plugin. Version 2.8.4 has not been updated for 4 years.

PCRE to PCRE2

The transition from PHP 7.2.x to PHP 7.3.x upgraded the PCRE (Perl Compatible Regular Expressions) extension to PCRE2. User ‘baseapp’ identified the problem was in function clean_id of class CrayonLang:

The preg_replace function performs a regular expression search and replace. The fix changes the pattern from /[^\w-+#]/msi to /[^\w\-+#]/msi. In particular, the character class changes from the negation (^) of \w-+# to the negation of \w\-+#. The hyphen (-) is now escaped (\-); otherwise it would be interpreted as a metacharacter indicating a character range.

I identified a similar problem with a line of the YAML language definition:

preg_quote

From PHP 7.3.0, the # character is quoted by function preg_quote. That affects the logic of the lines function of the CrayonUtil class:

CrayonParser::validate_regex

In order to identify problems with invalid regular expressions, I extended part of the CrayonParser::validate_regex function: