File tree Expand file tree Collapse file tree
user_guide_src/source/changelogs Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -300,11 +300,10 @@ public function getScriptNonce(): string
300300 */
301301 public function finalize (ResponseInterface $ response )
302302 {
303- if ($ this ->autoNonce === false ) {
304- return ;
303+ if ($ this ->autoNonce ) {
304+ $ this -> generateNonces ( $ response ) ;
305305 }
306306
307- $ this ->generateNonces ($ response );
308307 $ this ->buildHeaders ($ response );
309308 }
310309
Original file line number Diff line number Diff line change 1212namespace CodeIgniter \HTTP ;
1313
1414use CodeIgniter \Test \CIUnitTestCase ;
15+ use CodeIgniter \Test \TestResponse ;
1516use Config \App ;
1617use Config \ContentSecurityPolicy as CSPConfig ;
1718
@@ -533,6 +534,9 @@ public function testBodyScriptNonceDisableAutoNonce()
533534 $ csp ->finalize ($ response );
534535
535536 $ this ->assertStringContainsString ('{csp-script-nonce} ' , $ response ->getBody ());
537+
538+ $ result = new TestResponse ($ response );
539+ $ result ->assertHeader ('Content-Security-Policy ' );
536540 }
537541
538542 public function testBodyStyleNonceDisableAutoNonce ()
@@ -549,6 +553,9 @@ public function testBodyStyleNonceDisableAutoNonce()
549553 $ csp ->finalize ($ response );
550554
551555 $ this ->assertStringContainsString ('{csp-style-nonce} ' , $ response ->getBody ());
556+
557+ $ result = new TestResponse ($ response );
558+ $ result ->assertHeader ('Content-Security-Policy ' );
552559 }
553560
554561 /**
Original file line number Diff line number Diff line change 3333Bugs Fixed
3434**********
3535
36- none .
36+ - Fixed a bug that prevents CSP headers from being sent when `` Config\ContentSecurityPolicy::$autoNonce `` is false .
3737
3838See the repo's `CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md >`_ for a complete list of bugs fixed.
You can’t perform that action at this time.
0 commit comments