From 2ce6b63247af9c1940a4753382ff7e21cc8b5559 Mon Sep 17 00:00:00 2001 From: Jisse Reitsma Date: Wed, 2 Oct 2024 19:45:22 +0200 Subject: [PATCH] Prevent null HTML from causing errors --- CHANGELOG.md | 4 ++++ Plugin/AddCspInlineScripts.php | 2 +- composer.json | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43aa085..f5bd3a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.1.1] - 2 October 2024 +### Fixed +- Prevent null HTML from causing errors + ## [0.1.0] - 4 September 2024 ### Added - New default mode `custom` to only allow blocks that are explicitly whitelisted diff --git a/Plugin/AddCspInlineScripts.php b/Plugin/AddCspInlineScripts.php index 20076f3..8918333 100644 --- a/Plugin/AddCspInlineScripts.php +++ b/Plugin/AddCspInlineScripts.php @@ -31,7 +31,7 @@ public function __construct( public function afterToHtml(Template $block, $html): string { if (false === $this->allowBlock->allow($block)) { - return $html; + return (string)$html; } if (true === $this->config->logging()) { diff --git a/composer.json b/composer.json index 475817f..37fcf51 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "yireo/magento2-csp-whitelist-inline-js", - "version": "0.1.0", + "version": "0.1.1", "description": "Magento module to automatically add inline JS script to CSP whitelist", "type": "magento2-module", "require": {