HTML tags in scripts shouldn’t get modified
Closed this issue · 1 comments
ausi commented
If a JS templates includes something like alert('<div>')
the frontend helper currently injects the data-frontend-helper
attribute into the <div>
.
ausi commented
Could possibly be fixed by replacing
contao-rocksolid-frontend-helper/src/FrontendHooks.php
Lines 292 to 299 in 1a0bf45
// Remove dummy elements inside script tags and insert them before the script tags
$content = preg_replace_callback('(<script(?>"[^"]*"|\'[^\']*\'|[^>"\'])*>.*?</script>)is', function($matches) {
preg_match_all('(<span class="rsfh-dummy[^>]*></span>)is', $matches[0], $dummies);
if (count($dummies[0])) {
$matches[0] = str_replace($dummies[0], '', $matches[0]);
}
preg_match_all('( data-frontend-helper="[^"]*")is', $matches[0], $attributes);
if (count($attributes[0])) {
$matches[0] = '<span class="rsfh-dummy"' . implode(
'></span><span class="rsfh-dummy"',
$attributes[0]
) . '></span>' . str_replace($attributes[0], '', $matches[0]);
}
if (count($dummies[0])) {
$matches[0] = implode('', $dummies[0]) . $matches[0];
}
return $matches[0];
}, $content);