Fixed bug on domain block entity format check

This commit is contained in:
pezcurrel 2022-12-30 14:07:22 +01:00
parent 90e2263af8
commit f2d4119dfa

View file

@ -394,8 +394,8 @@ if ($idata['IsMastodon'] && $idata['Version']>='4.0.0') {
eecho(1,'«'.$opts['hostname'].'»: got instance domain blocks from API v1 :-)'.N);
$idata['blocks']=[];
foreach ($buf as $key=>$block) {
if (make(['domain', 'digest', 'severity', 'comment'],$block) && is_string($block['domain']) && !isempty($block['domain']) && is_string($block['digest']) && preg_match('/^[a-f0-9]{64}$/',$block['digest'])===1 && is_string($block['severity']) && in_array($block['severity'], ['silence','suspend']) && is_string($block['comment'])) {
if (trim($block['comment'])=='') $block['comment']=null;
if (make(['domain', 'digest', 'severity', 'comment'],$block) && is_string($block['domain']) && !isempty($block['domain']) && is_string($block['digest']) && preg_match('/^[a-f0-9]{64}$/',$block['digest'])===1 && is_string($block['severity']) && in_array($block['severity'], ['silence','suspend']) && (is_null($block['comment']) || is_string($block['comment']))) {
if (!is_null($block['comment']) && trim($block['comment'])=='') $block['comment']=null;
$idata['blocks'][]=['dom'=>$block['domain'], 'sev'=>$block['severity'], 'comm'=>$block['comment']];
} else {
eecho(2,'«'.$opts['hostname'].'»: domain block '.$key.' has unexpected format.'.N);