Convert tags from user-supplied string to array once, on input

This results in a fuckton of refactoring and code cancelling out
other code -- we no longer have a whole bunch of places trying
to support string params and array params, and doing their own
esaping and unescaping, never being quite sure if the data they've
been passed is escaped or not.

Also adds a bunch of type hinting, since we can now know what
data we're dealing with better.
This commit is contained in:
Shish
2016-07-30 22:11:49 +01:00
parent bc3e482247
commit 7be951b271
12 changed files with 139 additions and 188 deletions

View File

@ -271,12 +271,8 @@ class OuroborosPost extends _SafeOuroborosImage
public function __construct(array $post, $md5 = '')
{
if (array_key_exists('tags', $post)) {
$this->tags = Tag::implode(
array_map(
array('Tag', 'sanitise'),
Tag::explode(urldecode($post['tags']))
)
);
// implode(explode()) to resolve aliases and sanitise
$this->tags = Tag::implode(Tag::explode(urldecode($post['tags'])));
}
if (array_key_exists('file', $post)) {
if (!is_null($post['file'])) {