Merge pull request #10618 from MrPetovan/task/10603-ap-string-mentions

Escape url tags before attempting to add missing mention links in Protocol\ActivityPub\Processor
This commit is contained in:
Michael Vogel 2021-08-20 10:16:30 +02:00 committed by GitHub
commit 1d5427aca8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 12 deletions

View file

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

View file

@ -70,6 +70,17 @@ class ProcessorTest extends TestCase
]
],
],
'issue-10617' => [
'expected' => '@[url=https://mastodon.technology/@sergey_m]sergey_m[/url]',
'body' => '@[url=https://mastodon.technology/@sergey_m]sergey_m[/url]',
'tags' => [
[
'type' => 'Mention',
'href' => 'https://mastodon.technology/@sergey_m',
'name' => '@sergey_m'
],
],
],
];
}