diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 9fe2e4eba..605b28f5c 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -989,7 +989,11 @@ class Activity { if ($token && $has_images) { for ($n = 0; $n < count($images); $n ++) { $match = $images[$n]; - if (strpos($match[2],z_root() . '/photo/') !== false) { + if (strpos($match[1],'=http') === 0 && strpos($match[1],'/photo/' !== false)) { + $i['body'] = str_replace($match[1],$match[1] . '?token=' . $token, $i['body']); + $images[$n][2] = substr($match[1],1) . '?token=' . $token; + } + elseif (strpos($match[2],z_root() . '/photo/') !== false) { $i['body'] = str_replace($match[2],$match[2] . '?token=' . $token, $i['body']); $images[$n][2] = $match[2] . '?token=' . $token; } @@ -1053,13 +1057,20 @@ class Activity { if ($activitypub && $has_images && $ret['type'] === 'Note') { $img = []; foreach ($images as $match) { - $img[] = [ 'type' => 'Image', 'url' => $match[2] ]; + // handle Friendica-style img links with [img=$url]$alttext[/img] + if (strpos($match,'=http') === 0) { + $img[] = [ 'type' => 'Image', 'url' => substr($match[1],1) ]; + } + else { + $img[] = [ 'type' => 'Image', 'url' => $match[2] ]; + } + + if (! $ret['attachment']) { + $ret['attachment'] = []; + } + $ret['attachment'] = array_merge($img,$ret['attachment']); } - if (! $ret['attachment']) { - $ret['attachment'] = []; - } - $ret['attachment'] = array_merge($img,$ret['attachment']); - } + } // addressing madness diff --git a/include/items.php b/include/items.php index c1241b9da..b2d22e3ee 100644 --- a/include/items.php +++ b/include/items.php @@ -1367,7 +1367,12 @@ function purify_imported_object($obj) { $ret = null; if (is_array($obj)) { foreach ( $obj as $k => $v ) { - $ret[$k] = purify_html($v); + if (is_array($v)) { + $ret[$k] = purify_imported_object($v); + } + elseif (is_string($v)) { + $ret[$k] = purify_html($v); + } } } elseif (is_string($obj)) {