diff --git a/htdocs/website/index.php b/htdocs/website/index.php index d5d381093d5..3efad89cb4d 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2976,15 +2976,15 @@ if ($action == 'removecspsource' && $usercanedit) { $db->begin(); $sourcecsp = explode("_", GETPOST("sourcecsp")); $directive = $sourcecsp[0]; - $sourcekey = $sourcecsp[1]; - $sourcedata = $sourcecsp[2]; + $sourcekey = !empty($sourcecsp[1]) ? $sourcecsp[1] : null; + $sourcedata = !empty($sourcecsp[2]) ? $sourcecsp[2] : null; $forceCSPArr = websiteGetContentPolicyToArray($forceCSP); $directivesarray = websiteGetContentPolicyDirectives(); $sourcesarray = websiteGetContentPolicySources(); if (empty($directive)) { $error++; } - if ($error || (!is_null($sourcekey) && $directivesarray[$directive]["data-directivetype"] != "none")) { + if ($error || (!isset($sourcekey) && $directivesarray[$directive]["data-directivetype"] != "none")) { $error++; } diff --git a/htdocs/website/lib/website.lib.php b/htdocs/website/lib/website.lib.php index c26cdfb2a18..6da0d3693db 100644 --- a/htdocs/website/lib/website.lib.php +++ b/htdocs/website/lib/website.lib.php @@ -94,7 +94,7 @@ function websiteconfigPrepareHead($object) /** * Prepare array of directives for Website * - * @return array Array of directives + * @return array> Array of directives */ function websiteGetContentPolicyDirectives() { @@ -136,7 +136,7 @@ function websiteGetContentPolicyDirectives() /** * Prepare array of sources for Website * - * @return array Array of sources + * @return array>> Array of sources */ function websiteGetContentPolicySources() { @@ -190,7 +190,7 @@ function websiteGetContentPolicySources() * Transform a Content Security Policy to an array * @param string $forceCSP content security policy * - * @return array Array of sources + * @return array, list|string>> Array of sources */ function websiteGetContentPolicyToArray($forceCSP) {