Skip to content
Snippets Groups Projects
Commit f6b1080c authored by Jan Leehr's avatar Jan Leehr Committed by Ruud Simons
Browse files

Issue #3416470 by J-Lee: CSP form submit issues

parent 408329c1
No related branches found
No related tags found
1 merge request!1Skip disabled policies and option s without configurable URLs
......@@ -52,9 +52,15 @@ function csp_google_form_csp_settings_form_submit(array &$form, FormStateInterfa
$values = $form_state->getValues();
foreach (['report-only', 'enforce'] as $policy_type_key) {
$policy_type_key_config = $config->get($policy_type_key);
// Skip disabled policies.
if ($policy_type_key_config['enable'] === FALSE) {
continue;
}
foreach ($policy_type_key_config['directives'] as $key => $value) {
$csp_google_add_google_domain_sources = $values[$policy_type_key]['directives'][$key]['options']['csp_google_add_google_domain_sources'] ?? FALSE;
$policy_type_key_config['directives'][$key]['csp_google_add_google_domain_sources'] = $csp_google_add_google_domain_sources;
$csp_google_add_google_domain_sources = (bool) $values[$policy_type_key]['directives'][$key]['options']['csp_google_add_google_domain_sources'] ?? FALSE;
if (is_array($policy_type_key_config['directives'][$key])) {
$policy_type_key_config['directives'][$key]['csp_google_add_google_domain_sources'] = $csp_google_add_google_domain_sources;
}
}
$config->set($policy_type_key, $policy_type_key_config);
}
......
......@@ -59,7 +59,7 @@ class CspPolicy implements EventSubscriberInterface {
if (!$policy->hasDirective($key)) {
continue;
}
if (!$value['csp_google_add_google_domain_sources']) {
if (!is_array($value) || !$value['csp_google_add_google_domain_sources']) {
continue;
}
......@@ -77,8 +77,8 @@ class CspPolicy implements EventSubscriberInterface {
if (!in_array($supported_domain, $directive)) {
$directive[] = $supported_domain;
}
$policy->setDirective($key, $directive);
}
$policy->setDirective($key, $directive);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment