From 220227fa868f646ea276f27bd53ba4cfa53e26e4 Mon Sep 17 00:00:00 2001 From: Patrick Niebeling Date: Thu, 12 Nov 2026 22:54:08 +0100 Subject: [PATCH] Stop FormHelper from emitting inline validity handlers Required fields got generated oninvalid/oninput attributes, which the CSP blocks and logs on every page and when parsing dashboard fragments. Co-Authored-By: Claude Sonnet 5.5 --- src/View/AppView.php | 2 ++ tests/TestCase/Controller/AdminFragmentTest.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/View/AppView.php b/src/View/AppView.php index 9e94463..5a2fc5e 100644 --- a/src/View/AppView.php +++ b/src/View/AppView.php @@ -38,5 +38,7 @@ class AppView extends View public function initialize(): void { $this->addHelper('Format'); + // No generated oninvalid/oninput handlers: the CSP blocks inline event handlers. + $this->addHelper('Form', ['autoSetCustomValidity' => false]); } } diff --git a/tests/TestCase/Controller/AdminFragmentTest.php b/tests/TestCase/Controller/AdminFragmentTest.php index a1968f9..d21c3ea 100644 --- a/tests/TestCase/Controller/AdminFragmentTest.php +++ b/tests/TestCase/Controller/AdminFragmentTest.php @@ -64,6 +64,8 @@ class AdminFragmentTest extends TestCase $this->assertResponseNotContains('onclick='); $this->assertResponseContains('data-confirm='); + // Required fields (settings form) must not get generated oninvalid/oninput handlers, the CSP blocks them. + $this->assertDoesNotMatchRegularExpression('/\son[a-z]+="/', (string)$this->_response->getBody()); } public function testSlideFormFragmentIsTheDialogContent(): void -- 2.54.1