File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -89,16 +89,16 @@ public function attachHoneypot(ResponseInterface $response)
8989
9090 $ prepField = $ this ->prepareTemplate ($ this ->config ->template );
9191
92- $ body = $ response ->getBody ();
93- $ body = str_ireplace ('</form> ' , $ prepField . '</form> ' , $ body );
92+ $ bodyBefore = $ response ->getBody ();
93+ $ bodyAfter = str_ireplace ('</form> ' , $ prepField . '</form> ' , $ bodyBefore );
9494
95- if ($ response ->getCSP ()->enabled ()) {
95+ if ($ response ->getCSP ()->enabled () && ( $ bodyBefore !== $ bodyAfter ) ) {
9696 // Add style tag for the container tag in the head tag.
97- $ style = '<style ' . csp_style_nonce () . '># ' . $ this ->config ->containerId . ' { display:none }</style> ' ;
98- $ body = str_ireplace ('</head> ' , $ style . '</head> ' , $ body );
97+ $ style = '<style ' . csp_style_nonce () . '># ' . $ this ->config ->containerId . ' { display:none }</style> ' ;
98+ $ bodyAfter = str_ireplace ('</head> ' , $ style . '</head> ' , $ bodyAfter );
9999 }
100100
101- $ response ->setBody ($ body );
101+ $ response ->setBody ($ bodyAfter );
102102 }
103103
104104 /**
You can’t perform that action at this time.
0 commit comments