self::MAX_BYTES){throw new RuntimeException('exclusion_source_too_large');} $list=@unserialize($raw,array('allowed_classes'=>false)); if(!is_array($list) || !array_is_list($list) || serialize($list)!==$raw){throw new RuntimeException('exclusion_source_invalid');} if(count($list)>self::MAX_ENTRIES){throw new RuntimeException('exclusion_source_too_large');} $hashes=array(); foreach($list as $entry){ if(!is_array($entry) || !in_array($entry['field']??null,array('email','phone','name'),true)){throw new RuntimeException('exclusion_source_invalid');} $values=array(); if(array_key_exists('hashes',$entry)){ if(!is_array($entry['hashes']) || !array_is_list($entry['hashes'])){throw new RuntimeException('exclusion_source_invalid');} if(count($entry['hashes'])>self::MAX_HASHES){throw new RuntimeException('exclusion_source_too_large');} $values=$entry['hashes']; } if(array_key_exists('hash',$entry)){$values[]=$entry['hash'];} if(!$values){throw new RuntimeException('exclusion_source_invalid');} foreach($values as $hash){ if(!is_string($hash) || !preg_match('/^[a-f0-9]{64}$/D',$hash)){throw new RuntimeException('exclusion_source_invalid');} $hashes[$hash]=true; if(count($hashes)>self::MAX_HASHES){throw new RuntimeException('exclusion_source_too_large');} } } $result=array_keys($hashes);sort($result,SORT_STRING);return $result; } }