@@ -698,4 +698,36 @@ public function testSendRemovesMultiplePlaceholdersWhenCSPDisabled(): void
698698 $ this ->assertStringContainsString ('<style >.test{}</style> ' , $ actual );
699699 $ this ->assertStringContainsString ('<style >.test2{}</style> ' , $ actual );
700700 }
701+
702+ public function testSendRemovesPlaceholdersWhenBothCSPAndAutoNonceAreDisabled (): void
703+ {
704+ $ appConfig = new App ();
705+ $ appConfig ->CSPEnabled = false ;
706+
707+ // Create custom CSP config with custom nonce tags
708+ $ cspConfig = new \Config \ContentSecurityPolicy ();
709+ $ cspConfig ->autoNonce = false ;
710+
711+ $ response = new Response ($ appConfig );
712+ $ response ->pretend (true );
713+
714+ // Inject the custom CSP config
715+ $ reflection = new ReflectionClass ($ response );
716+ $ cspProperty = $ reflection ->getProperty ('CSP ' );
717+ $ cspProperty ->setValue ($ response , new ContentSecurityPolicy ($ cspConfig ));
718+
719+ $ body = '<html><script {csp-script-nonce}>test()</script><style {csp-style-nonce}>.x{}</style></html> ' ;
720+ $ response ->setBody ($ body );
721+
722+ ob_start ();
723+ $ response ->send ();
724+ $ actual = ob_get_clean ();
725+
726+ // Custom nonce placeholders should be removed when CSP is disabled
727+ $ this ->assertIsString ($ actual );
728+ $ this ->assertStringNotContainsString ('{csp-script-nonce} ' , $ actual );
729+ $ this ->assertStringNotContainsString ('{csp-style-nonce} ' , $ actual );
730+ $ this ->assertStringContainsString ('<script >test()</script> ' , $ actual );
731+ $ this ->assertStringContainsString ('<style >.x{}</style> ' , $ actual );
732+ }
701733}
0 commit comments