-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Web] fix exception handler and rspamd_maps function #5818
Conversation
I might be wrong about this, but I think that one of the commits that is part of this PR (3aee2b6) introduces a potential bug. I say potential, because due to circumstances, this bug is not triggered at the moment but lies dormant instead. The problem is with the fix in This is the problematic section of the code: $maps = (array)$_data['map'];
$valid_maps = array();
foreach ($maps as $map) {
foreach ($RSPAMD_MAPS as $rspamd_map_type) {
if (!in_array($map, $rspamd_map_type)) {
$_SESSION['return'][] = array(
'type' => 'danger',
'log' => array(__FUNCTION__, $_action, '-'),
'msg' => array('global_map_invalid', $map)
);
} else {
array_push($valid_maps, $map);
}
}
} The bug lies dormant because according to Consider the case, where a second element is added to I think that the correct way to fix this is doing the adding to either of the arrays outside of the inner loop, so the code could look like this: $maps = (array)$_data['map'];
$valid_maps = array();
foreach ($maps as $map) {
$map_is_valid = false;
foreach ($RSPAMD_MAPS as $rspamd_map_type) {
if (in_array($map, $rspamd_map_type)) {
$map_is_valid = true;
break; // break the inner loop
}
}
if ($map_is_valid) {
array_push($valid_maps, $map);
} else {
$_SESSION['return'][] = array(
'type' => 'danger',
'log' => array(__FUNCTION__, $_action, '-'),
'msg' => array('global_map_invalid', $map)
);
}
} This way, |
@smarsching You are correct, thank you for pointing this out. I will prepare a PR for this. |
@smarsching see 7660ca8 |
@FreddleSpl0it Looks good now. Thanks for fixing it so quickly. |
No description provided.