Strip script and style tags from feed output
This commit is contained in:
parent
449e6f8e03
commit
0866fe93ba
1 changed files with 6 additions and 0 deletions
|
|
@ -104,6 +104,12 @@ if (str_ends_with($ctx->requestPath, 'feed.xml')) {
|
||||||
foreach ($contentFiles as $file) {
|
foreach ($contentFiles as $file) {
|
||||||
$item['content'] .= renderContentFile($file, $ctx);
|
$item['content'] .= renderContentFile($file, $ctx);
|
||||||
}
|
}
|
||||||
|
// Strip <script> and <style> blocks — not useful in feed readers
|
||||||
|
$stripped = preg_replace('#<script[^>]*>.*?</script>#is', '', $item['content']);
|
||||||
|
if ($stripped !== null) {
|
||||||
|
$stripped = preg_replace('#<style[^>]*>.*?</style>#is', '', $stripped);
|
||||||
|
}
|
||||||
|
$item['content'] = $stripped ?? $item['content'];
|
||||||
}
|
}
|
||||||
unset($item);
|
unset($item);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue