From: Alexander Ebert Date: Mon, 21 Jun 2021 14:08:30 +0000 (+0200) Subject: Improved the regex for simple embedded objects X-Git-Tag: 5.4.0_RC_1~30 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1373c84f26ccd4231cf7a3cea99f7db8ccebc7f2;p=GitHub%2FWoltLab%2FWCF.git Improved the regex for simple embedded objects The previous version was borderline erroneous and while it worked so far, it could easily break in future versions of PHP. --- diff --git a/wcfsetup/install/files/lib/system/html/simple/HtmlSimpleParser.class.php b/wcfsetup/install/files/lib/system/html/simple/HtmlSimpleParser.class.php index 497454bf57..cc45be186d 100644 --- a/wcfsetup/install/files/lib/system/html/simple/HtmlSimpleParser.class.php +++ b/wcfsetup/install/files/lib/system/html/simple/HtmlSimpleParser.class.php @@ -35,7 +35,7 @@ class HtmlSimpleParser extends SingletonFactory * regex for simple placeholders * @var string */ - protected $regexHandlers = '~{{\ ((?:[a-z][a-zA-Z]+="(?:\\"|[^"])+?"\ ?)*)\ }}~'; + protected $regexHandlers = '~\{\{ ((?:[a-z][a-zA-Z]+="(?:\\\\"|[^"])+" ?)*) \}\}~'; /** * @inheritDoc @@ -77,7 +77,6 @@ class HtmlSimpleParser extends SingletonFactory foreach ($matches[1] as $attributesString) { $attributes = $this->parseAttributes($attributesString); $handler = $attributes['handler']; - if (!isset($this->handlers[$handler])) { // unknown handler, ignore continue; @@ -182,7 +181,7 @@ class HtmlSimpleParser extends SingletonFactory */ protected function parseAttributes($attributesString) { - \preg_match_all('~([a-z][a-zA-Z]+)="((?:\\\\"|[^"])+?)"~', $attributesString, $attributes); + \preg_match_all('~([a-z][a-zA-Z]+)="((?:\\\\"|[^"])+)"~', $attributesString, $attributes); $additionalAttributes = []; for ($i = 1, $length = \count($attributes[0]); $i < $length; $i++) {