Escape url tags before attempting to add missing mention links in Protocol\ActivityPub\Processor

- Mastodon uses @-sign in profile URLs which wrongly triggered the mention link add in existing mentions links
This commit is contained in:
Hypolite Petovan 2021-08-20 03:40:23 -04:00
parent 4b36f7e8c8
commit 1de159a2ae

View file

@ -1207,6 +1207,7 @@ class Processor
// This prevents links to be added again to Pleroma-style mention links // This prevents links to be added again to Pleroma-style mention links
$body = self::normalizeMentionLinks($body); $body = self::normalizeMentionLinks($body);
$body = BBCode::performWithEscapedTags($body, ['url'], function ($body) use ($tags) {
foreach ($tags as $tag) { foreach ($tags as $tag) {
if (empty($tag['name']) || empty($tag['type']) || empty($tag['href']) || !in_array($tag['type'], ['Mention', 'Hashtag'])) { if (empty($tag['name']) || empty($tag['type']) || empty($tag['href']) || !in_array($tag['type'], ['Mention', 'Hashtag'])) {
continue; continue;
@ -1222,6 +1223,9 @@ class Processor
$body = str_replace($tag['name'], $hash . '[url=' . $tag['href'] . ']' . $name . '[/url]', $body); $body = str_replace($tag['name'], $hash . '[url=' . $tag['href'] . ']' . $name . '[/url]', $body);
} }
return $body;
});
return $body; return $body;
} }
} }