Merge branch 'cherry-pick-7cc8c2d1' into 'dev'

port fixes from zap to check for arrays

See merge request hubzilla/core!1767
This commit is contained in:
M. Dent 2019-11-06 04:13:57 +01:00
commit 2a05bd9ed6

View File

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