From 2aa4d5fa92d1a0f93d8a8f2f98601b79a584da44 Mon Sep 17 00:00:00 2001 From: Simon Erkelens Date: Fri, 21 Jul 2023 12:06:30 +1200 Subject: [PATCH] Harden datarecord check --- src/Extensions/ControllerCSPExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Extensions/ControllerCSPExtension.php b/src/Extensions/ControllerCSPExtension.php index 4f269fe..69e4b03 100644 --- a/src/Extensions/ControllerCSPExtension.php +++ b/src/Extensions/ControllerCSPExtension.php @@ -260,7 +260,7 @@ private function addCSPHeaders(mixed $ymlConfig, Controller $owner): void $legacy = $config['legacy'] ?? true; $unsafeCSSInline = $config['style-src']['unsafe-inline']; $unsafeJsInline = $config['script-src']['unsafe-inline']; - if (class_exists('\Page')) { + if (class_exists('\Page') && $owner && $owner->dataRecord) { $config['style-src']['unsafe-inline'] = $unsafeCSSInline || $owner->dataRecord->AllowCSSInline; $config['script-src']['unsafe-inline'] = $unsafeJsInline || $owner->dataRecord->AllowJSInline; }