finishing changes in models, removing last md5 test cases, tightening up allowed POST data

This commit is contained in:
El RIDO 2019-05-06 22:15:21 +02:00
parent 06b90ff48e
commit 76dc01b959
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92
7 changed files with 236 additions and 339 deletions

View file

@ -32,10 +32,12 @@ class FormatV2
*/
public static function isValid($message, $isComment = false)
{
$required_keys = array('adata', 'meta', 'v', 'ct');
$required_keys = array('adata', 'v', 'ct');
if ($isComment) {
$required_keys[] = 'pasteid';
$required_keys[] = 'parentid';
} else {
$required_keys[] = 'meta';
}
// Make sure no additionnal keys were added.
@ -109,6 +111,15 @@ class FormatV2
return false;
}
// require only the key 'expire' in the metadata of pastes
if (!$isComment && (
count($message['meta']) === 0 ||
!array_key_exists('expire', $message['meta']) ||
count($message['meta']) > 1
)) {
return false;
}
return true;
}
}