diff --git a/common/framework/parsers/template/TemplateParser_v2.php b/common/framework/parsers/template/TemplateParser_v2.php index f85f30ccc..d71af7947 100644 --- a/common/framework/parsers/template/TemplateParser_v2.php +++ b/common/framework/parsers/template/TemplateParser_v2.php @@ -179,14 +179,18 @@ class TemplateParser_v2 */ protected function _addContextSwitches(string $content): string { + $context_index = random_int(12000, 99000); + // Inline styles. $content = preg_replace_callback('#(?<=\s)(style=")([^"]*?)"#i', function($match) { return $match[1] . 'config->context = \'CSS\'; ?>' . $match[2] . 'config->context = \'HTML\'; ?>"'; }, $content); // Inline scripts. - $content = preg_replace_callback('#(?<=\s)(href="javascript:|pattern="|on[a-z]+=")([^"]*?)"#i', function($match) { - return $match[1] . 'config->context = \'JS\'; ?>' . $match[2] . 'config->context = \'HTML\'; ?>"'; + $content = preg_replace_callback('#(?<=\s)(href="javascript:|pattern="|on[a-z]+=")([^"]*?)"#i', function($match) use(&$context_index) { + $context_index++; + return $match[1] . 'config->context = \'JS\'; /* !CTX' . $context_index . '! */?>' . + $match[2] . 'config->context = \'HTML\'; /* !CTX' . $context_index . '! */?>"'; }, $content); //