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