@@ -937,67 +937,4 @@ public function testClearDirective(): void
937937 $ this ->assertNotContains ('report-uri http://example.com/csp/reports ' , $ directives );
938938 $ this ->assertNotContains ('report-to default ' , $ directives );
939939 }
940-
941- public function testClearNoncePlaceholdersWithDefaultTags (): void
942- {
943- $ config = new CSPConfig ();
944- $ csp = new ContentSecurityPolicy ($ config );
945-
946- $ body = 'Test {csp-script-nonce} and {csp-style-nonce} here ' ;
947- $ cleaned = $ csp ->clearNoncePlaceholders ($ body );
948-
949- $ this ->assertSame ('Test and here ' , $ cleaned );
950- $ this ->assertStringNotContainsString ('{csp-script-nonce} ' , $ cleaned );
951- $ this ->assertStringNotContainsString ('{csp-style-nonce} ' , $ cleaned );
952- }
953-
954- public function testClearNoncePlaceholdersWithCustomTags (): void
955- {
956- $ config = new CSPConfig ();
957- $ config ->scriptNonceTag = '{custom-script-nonce} ' ;
958- $ config ->styleNonceTag = '{custom-style-nonce} ' ;
959- $ csp = new ContentSecurityPolicy ($ config );
960-
961- $ body = 'Test {custom-script-nonce} and {custom-style-nonce} here ' ;
962- $ cleaned = $ csp ->clearNoncePlaceholders ($ body );
963-
964- $ this ->assertSame ('Test and here ' , $ cleaned );
965- $ this ->assertStringNotContainsString ('{custom-script-nonce} ' , $ cleaned );
966- $ this ->assertStringNotContainsString ('{custom-style-nonce} ' , $ cleaned );
967- }
968-
969- public function testClearNoncePlaceholdersWithEmptyBody (): void
970- {
971- $ config = new CSPConfig ();
972- $ csp = new ContentSecurityPolicy ($ config );
973-
974- $ body = '' ;
975- $ cleaned = $ csp ->clearNoncePlaceholders ($ body );
976-
977- $ this ->assertSame ('' , $ cleaned );
978- }
979-
980- public function testClearNoncePlaceholdersWithNoPlaceholders (): void
981- {
982- $ config = new CSPConfig ();
983- $ csp = new ContentSecurityPolicy ($ config );
984-
985- $ body = 'Test body with no placeholders ' ;
986- $ cleaned = $ csp ->clearNoncePlaceholders ($ body );
987-
988- $ this ->assertSame ($ body , $ cleaned );
989- }
990-
991- public function testClearNoncePlaceholdersWithMultiplePlaceholders (): void
992- {
993- $ config = new CSPConfig ();
994- $ csp = new ContentSecurityPolicy ($ config );
995-
996- $ body = '<script {csp-script-nonce}>a</script><script {csp-script-nonce}>b</script><style {csp-style-nonce}>c</style> ' ;
997- $ cleaned = $ csp ->clearNoncePlaceholders ($ body );
998-
999- $ this ->assertStringNotContainsString ('{csp-script-nonce} ' , $ cleaned );
1000- $ this ->assertStringNotContainsString ('{csp-style-nonce} ' , $ cleaned );
1001- $ this ->assertSame ('<script >a</script><script >b</script><style >c</style> ' , $ cleaned );
1002- }
1003940}
0 commit comments