From f345b4e022999f4376ffdd6d09f5841bba2790e6 Mon Sep 17 00:00:00 2001 From: Simon Erkelens Date: Sat, 23 Sep 2023 22:43:03 +1200 Subject: [PATCH] strip_tags was too agressive Replaced with a regex that simply grabs whatever is inside the script. This is safer for e.g. variables that contain (pseudo)html --- src/View/CSPBackend.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/View/CSPBackend.php b/src/View/CSPBackend.php index db8d1ac..80c4fc0 100644 --- a/src/View/CSPBackend.php +++ b/src/View/CSPBackend.php @@ -61,8 +61,11 @@ public function insertHeadTags($html, $uniquenessID = null): void $type = $this->getTagType($html); if ($type === 'javascript') { $options = $this->getOptions($html); - static::$headJS[$uniquenessID] = [strip_tags($html) => $options]; - ControllerCSPExtension::addJS(strip_tags($html)); + // Grab everything between the script tags. All matches are okay, but the last one is the actual script content + preg_match('/