From: Alexander Ebert Date: Wed, 7 Mar 2018 22:53:24 +0000 (+0100) Subject: Optimized string matching for escaped quotes X-Git-Tag: 2.1.20~5 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=009578b6714a84a2e62db089a08e3485164d8f4a;p=GitHub%2FWoltLab%2FWCF.git Optimized string matching for escaped quotes The new regex is more efficient, because it tries to match as long as possible using repetitions of a character class, instead of repetitions of an alternation, leading to fewer internal states. --- diff --git a/wcfsetup/install/files/lib/system/bbcode/highlighter/Highlighter.class.php b/wcfsetup/install/files/lib/system/bbcode/highlighter/Highlighter.class.php index bd084db77a..810c47dcfb 100644 --- a/wcfsetup/install/files/lib/system/bbcode/highlighter/Highlighter.class.php +++ b/wcfsetup/install/files/lib/system/bbcode/highlighter/Highlighter.class.php @@ -179,7 +179,7 @@ abstract class Highlighter extends SingletonFactory { $closing = preg_quote($closing); if ($quotedEscapeSequence) { - $quotesRegEx .= $opening.'(?>[^'.$closing.$quotedEscapeSequence.']|'.$quotedEscapeSequence.'.)*'.$closing; + $quotesRegEx .= $opening.'(?>[^'.$closing.$quotedEscapeSequence.']+|('.$quotedEscapeSequence.'.)+)*'.$closing; } else { $quotesRegEx .= $opening.'(?>[^'.$closing.$quotedEscapeSequence.'])*'.$closing;