Fix for Mastodon falsely adding previews to mentions
This commit is contained in:
parent
d738ff37b2
commit
bb5f738619
2 changed files with 23 additions and 20 deletions
|
@ -1748,6 +1748,27 @@ class BBCode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle mentions and hashtag links
|
||||||
|
if ($simple_html == self::DIASPORA) {
|
||||||
|
// The ! is converted to @ since Diaspora only understands the @
|
||||||
|
$text = preg_replace("/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
||||||
|
'@<a href="$2">$3</a>',
|
||||||
|
$text);
|
||||||
|
} elseif (in_array($simple_html, [self::OSTATUS, self::ACTIVITYPUB])) {
|
||||||
|
$text = preg_replace("/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
||||||
|
'<span class="h-card"><a href="$2" class="u-url mention">$1<span>$3</span></a></span>',
|
||||||
|
$text);
|
||||||
|
$text = preg_replace("/([#])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
||||||
|
'<a href="$2" class="mention hashtag" rel="tag">$1<span>$3</span></a>',
|
||||||
|
$text);
|
||||||
|
} elseif (in_array($simple_html, [self::INTERNAL, self::EXTERNAL, self::API])) {
|
||||||
|
$text = preg_replace("/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
||||||
|
'<bdi>$1<a href="$2" class="userinfo mention" title="$3">$3</a></bdi>',
|
||||||
|
$text);
|
||||||
|
} else {
|
||||||
|
$text = preg_replace("/([#@!])\[url\=(.*?)\](.*?)\[\/url\]/ism", '$1$3', $text);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$for_plaintext) {
|
if (!$for_plaintext) {
|
||||||
if (in_array($simple_html, [self::OSTATUS, self::API, self::ACTIVITYPUB])) {
|
if (in_array($simple_html, [self::OSTATUS, self::API, self::ACTIVITYPUB])) {
|
||||||
$text = preg_replace_callback("/\[url\](.*?)\[\/url\]/ism", 'self::convertUrlForActivityPubCallback', $text);
|
$text = preg_replace_callback("/\[url\](.*?)\[\/url\]/ism", 'self::convertUrlForActivityPubCallback', $text);
|
||||||
|
@ -1758,24 +1779,6 @@ class BBCode
|
||||||
$text = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", 'self::removePictureLinksCallback', $text);
|
$text = preg_replace_callback("&\[url=([^\[\]]*)\]\[img\](.*)\[\/img\]\[\/url\]&Usi", 'self::removePictureLinksCallback', $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove all hashtag addresses
|
|
||||||
if ($simple_html && !in_array($simple_html, [self::DIASPORA, self::OSTATUS, self::ACTIVITYPUB])) {
|
|
||||||
$text = preg_replace("/([#@!])\[url\=(.*?)\](.*?)\[\/url\]/ism", '$1$3', $text);
|
|
||||||
} elseif ($simple_html == self::DIASPORA) {
|
|
||||||
// The ! is converted to @ since Diaspora only understands the @
|
|
||||||
$text = preg_replace("/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
|
||||||
'@<a href="$2">$3</a>',
|
|
||||||
$text);
|
|
||||||
} elseif (in_array($simple_html, [self::OSTATUS, self::ACTIVITYPUB])) {
|
|
||||||
$text = preg_replace("/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
|
||||||
'$1<span class="vcard"><a href="$2" class="url u-url mention" title="$3"><span class="fn nickname mention">$3</span></a></span>',
|
|
||||||
$text);
|
|
||||||
} elseif (!$simple_html) {
|
|
||||||
$text = preg_replace("/([@!])\[url\=(.*?)\](.*?)\[\/url\]/ism",
|
|
||||||
'<bdi>$1<a href="$2" class="userinfo mention" title="$3">$3</a></bdi>',
|
|
||||||
$text);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bookmarks in red - will be converted to bookmarks in friendica
|
// Bookmarks in red - will be converted to bookmarks in friendica
|
||||||
$text = preg_replace("/#\^\[url\](.*?)\[\/url\]/ism", '[bookmark=$1]$1[/bookmark]', $text);
|
$text = preg_replace("/#\^\[url\](.*?)\[\/url\]/ism", '[bookmark=$1]$1[/bookmark]', $text);
|
||||||
$text = preg_replace("/#\^\[url\=(.*?)\](.*?)\[\/url\]/ism", '[bookmark=$1]$2[/bookmark]', $text);
|
$text = preg_replace("/#\^\[url\=(.*?)\](.*?)\[\/url\]/ism", '[bookmark=$1]$2[/bookmark]', $text);
|
||||||
|
|
|
@ -1356,12 +1356,12 @@ class Transmitter
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = Contact::getByURL($match[1], false, ['url', 'alias', 'nick']);
|
$data = Contact::getByURL($match[1], false, ['url', 'nick']);
|
||||||
if (empty($data['nick'])) {
|
if (empty($data['nick'])) {
|
||||||
return $match[0];
|
return $match[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
return '[url=' . $data['url'] . ']@' . $data['nick'] . '[/url]';
|
return '@[url=' . $data['url'] . ']' . $data['nick'] . '[/url]';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue