$body =
$response->
getBody();
if (empty($body)) { return;
} // Replace style and script placeholders with nonces
$pattern = '/(' .
preg_quote($this->styleNonceTag, '/'
) . '|' .
preg_quote($this->scriptNonceTag, '/'
) . ')/';
$body =
preg_replace_callback($pattern,
function D
$match) { $nonce =
$match[0
] ===
$this->styleNonceTag ?
$this->
getStyleNonce() :
$this->
getScriptNonce();
return "nonce=\"{
$nonce}\"";
},
$body);
$response->
setBody($body);
} /**
* Based on the current state of the elements, will add the appropriate
* Content-Security-Policy and Content-Security-Policy-Report-Only headers
* with their values to the response object.
*
* @return void
*/