port fixes from zap to check for arrays

(cherry picked from commit 7cc8c2d127b09b7e53c7916c6ea104fa566971db)
This commit is contained in:
Mario 2019-11-04 11:14:44 +00:00
parent 64c6e25896
commit b359b89aa1

View File

@ -401,19 +401,23 @@ class Activity {
$ret = [];
if($item['tag']) {
foreach($item['tag'] as $t) {
if(! array_key_exists('type',$t))
if ($item['tag'] && is_array($item['tag'])) {
$ptr = $item['tag'];
if (! array_key_exists(0,$ptr)) {
$ptr = [ $ptr ];
}
foreach ($ptr as $t) {
if (! array_key_exists('type',$t))
$t['type'] = 'Hashtag';
switch($t['type']) {
case 'Hashtag':
$ret[] = [ 'ttype' => TERM_HASHTAG, 'url' => ((isset($t['href'])) ? $t['href'] : $t['id']), 'term' => escape_tags((substr($t['name'],0,1) === '#') ? substr($t['name'],1) : $t['name']) ];
$ret[] = [ 'ttype' => TERM_HASHTAG, 'url' => $t['href'], 'term' => escape_tags((substr($t['name'],0,1) === '#') ? substr($t['name'],1) : $t['name']) ];
break;
case 'Mention':
$mention_type = substr($t['name'],0,1);
if($mention_type === '!') {
if ($mention_type === '!') {
$ret[] = [ 'ttype' => TERM_FORUM, 'url' => $t['href'], 'term' => escape_tags(substr($t['name'],1)) ];
}
else {
@ -431,6 +435,7 @@ class Activity {
}
static function encode_taxonomy($item) {
$ret = [];