Billion laughs detection in wordfilters

This commit is contained in:
8chan 2015-02-16 16:11:21 -08:00
parent 0cef3a8d04
commit c3ff6daa53

View File

@ -14,6 +14,28 @@
}
}
if (!function_exists('is_billion_laughs')){
function is_billion_laughs($arr1, $arr2) {
$arr = array();
foreach ($arr1 as $k => $v) {
$arr[$v] = $arr2[$k];
}
for ($i = 0; $i <= sizeof($arr); $i++) {
$cur = array_slice($arr, $i, 1);
$pst = array_slice($arr, 0, $i);
if (!$cur) continue;
$kk = array_keys($cur)[0];
$vv = array_values($cur)[0];
foreach ($pst as $k => $v) {
if (str_replace($kk, $vv, $v) != $v)
return true;
}
}
return false;
}
}
$config['mod']['show_ip'] = GLOBALVOLUNTEER;
$config['mod']['show_ip_less'] = BOARDVOLUNTEER;
$config['mod']['manageusers'] = GLOBALVOLUNTEER;
@ -459,6 +481,9 @@ OEKAKI;
}
}
}
if (is_billion_laughs($_POST['replace'], $_POST['with'])) {
error(_('Wordfilters may not wordfilter previous wordfilters. For example, if a filters to bb and b filters to cc, that is not allowed.'));
}
}
if (isset($_POST['hour_max_threads']) && in_array($_POST['hour_max_threads'], ['10', '25', '50', '100'])) {