Escape meta attributes to avoid XSS injection

This commit is contained in:
Giuseppe Criscione 2024-06-07 11:30:16 +02:00
parent 257150aee2
commit f5312015a5

View File

@ -1,9 +1,9 @@
<?php foreach ($page->metadata() as $meta) : ?>
<?php if ($meta->isCharset()) : ?>
<meta charset="<?= $meta->content() ?>">
<meta charset="<?= $this->escapeAttr($meta->content()) ?>">
<?php elseif ($meta->isHTTPEquiv()) : ?>
<meta http-equiv="<?= $meta->name() ?>" content="<?= $meta->content() ?>">
<meta http-equiv="<?= $this->escapeAttr($meta->name()) ?>" content="<?= $this->escapeAttr($meta->content()) ?>">
<?php else : ?>
<meta <?= $meta->prefix() === 'og' ? 'property' : 'name' ?>="<?= $meta->name() ?>" content="<?= $meta->content() ?>">
<meta <?= $meta->prefix() === 'og' ? 'property' : 'name' ?>="<?= $this->escapeAttr($meta->name()) ?>" content="<?= $this->escapeAttr($meta->content()) ?>">
<?php endif ?>
<?php endforeach ?>