@@ -92,6 +92,15 @@ public function onKernelResponse(ResponseEvent $event)
92
92
return ;
93
93
}
94
94
95
+ $ nonces = [];
96
+ if ($ this ->cspHandler ) {
97
+ if ($ this ->dumpDataCollector && $ this ->dumpDataCollector ->getDumpsCount () > 0 ) {
98
+ $ this ->cspHandler ->disableCsp ();
99
+ }
100
+
101
+ $ nonces = $ this ->cspHandler ->updateResponseHeaders ($ request , $ response );
102
+ }
103
+
95
104
// do not capture redirects or modify XML HTTP Requests
96
105
if ($ request ->isXmlHttpRequest ()) {
97
106
return ;
@@ -118,23 +127,14 @@ public function onKernelResponse(ResponseEvent $event)
118
127
return ;
119
128
}
120
129
121
- $ this ->injectToolbar ($ response , $ request );
130
+ $ this ->injectToolbar ($ response , $ request, $ nonces );
122
131
}
123
132
124
133
/**
125
134
* Injects the web debug toolbar into the given Response.
126
135
*/
127
- protected function injectToolbar (Response $ response , Request $ request )
136
+ protected function injectToolbar (Response $ response , Request $ request, array $ nonces )
128
137
{
129
- $ nonces = [];
130
- if ($ this ->cspHandler ) {
131
- if ($ this ->dumpDataCollector && $ this ->dumpDataCollector ->getDumpsCount () > 0 ) {
132
- $ this ->cspHandler ->disableCsp ();
133
- }
134
-
135
- $ nonces = $ this ->cspHandler ->updateResponseHeaders ($ request , $ response );
136
- }
137
-
138
138
$ content = $ response ->getContent ();
139
139
$ pos = strripos ($ content , '</body> ' );
140
140
0 commit comments