Skip literal text in ActivityPub\Transmitter::removePictures

This commit is contained in:
Hypolite Petovan 2022-12-18 23:32:52 -05:00
parent e28be36086
commit 2372e50e3b

View File

@ -1477,12 +1477,13 @@ class Transmitter
*/
private static function removePictures(string $body): string
{
return BBCode::performWithEscapedTags($body, ['code', 'noparse', 'nobb', 'pre'], function ($text) {
// Simplify image codes
$body = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $body);
$body = preg_replace("/\[img\=(.*?)\](.*?)\[\/img\]/ism", '[img]$1[/img]', $body);
$text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $text);
$text = preg_replace("/\[img\=(.*?)\](.*?)\[\/img\]/ism", '[img]$1[/img]', $text);
// Now remove local links
$body = preg_replace_callback(
$text = preg_replace_callback(
'/\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]/Usi',
function ($match) {
// We remove the link when it is a link to a local photo page
@ -1492,13 +1493,12 @@ class Transmitter
// otherwise we just return the link
return '[url]' . $match[1] . '[/url]';
},
$body
$text
);
// Remove all pictures
$body = preg_replace("/\[img\]([^\[\]]*)\[\/img\]/Usi", '', $body);
return $body;
return preg_replace("/\[img\]([^\[\]]*)\[\/img\]/Usi", '', $text);
});
}
/**