From 6a7685f3153cffc44dfecd3e4f1b9a292ac5b7d2 Mon Sep 17 00:00:00 2001 From: shreypuranik Date: Wed, 15 Jul 2020 17:19:14 +0100 Subject: [PATCH] Readability update --- .../Csp/ContentSecurityPolicyHandler.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php b/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php index f75d29aea7..d27db85c9c 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php +++ b/src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php @@ -127,8 +127,15 @@ class ContentSecurityPolicyHandler $headers = $this->getCspHeaders($response); + $types = [ + 'script-src' => 'csp_script_nonce', + 'script-src-elem' => 'csp_script_nonce', + 'style-src' => 'csp_style_nonce', + 'style-src-elem' => 'csp_style_nonce' + ]; + foreach ($headers as $header => $directives) { - foreach (['script-src' => 'csp_script_nonce', 'script-src-elem' => 'csp_script_nonce', 'style-src' => 'csp_style_nonce', 'style-src-elem' => 'csp_style_nonce'] as $type => $tokenName) { + foreach ($types as $type => $tokenName) { if ($this->authorizesInline($directives, $type)) { continue; }