X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fbbcode.php;h=9a43cdb305e140222650bcfdd9dd97f307da934b;hb=34815de99c548b61c94b6e6939edd485eca728d6;hp=4b5384a615f183b1190426d7c6058fac177665a8;hpb=aa4eafc30450dcbb0d80cd66d6c01f248a726d38;p=friendica.git
diff --git a/include/bbcode.php b/include/bbcode.php
index 4b5384a615..9a43cdb305 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -55,18 +55,7 @@ function bb_attachment($Text, $simplehtml = false, $tryoembed = true) {
}
if ($simplehtml == 7) {
- $title2 = $data["title"];
-
- $test1 = trim(html_entity_decode($data["text"],ENT_QUOTES,'UTF-8'));
- $test2 = trim(html_entity_decode($data["title"],ENT_QUOTES,'UTF-8'));
-
- // If the link description is similar to the text above then don't add the link description
- if (($data["title"] != "") AND ((strpos($test1,$test2) !== false) OR
- (similar_text($test1,$test2) / strlen($data["title"])) > 0.9)) {
- $title2 = $data["url"];
- }
- $text = sprintf('%s
',
- $data["url"], $data["title"], $title2);
+ $text = style_url_for_mastodon($data["url"]);
} elseif (($simplehtml != 4) AND ($simplehtml != 0)) {
$text = sprintf('%s
', $data["url"], $data["title"]);
} else {
@@ -170,6 +159,11 @@ function cleancss($input) {
return $cleaned;
}
+/**
+ * @brief Converts [url] BBCodes in a format that looks fine on Mastodon. (callback function)
+ * @param array $match Array with the matching values
+ * @return string reformatted link including HTML codes
+ */
function bb_style_url($match) {
$url = $match[1];
@@ -182,12 +176,22 @@ function bb_style_url($match) {
return $match[0];
}
+ return style_url_for_mastodon($url);
+}
+
+/**
+ * @brief Converts [url] BBCodes in a format that looks fine on Mastodon and GNU Social.
+ * @param string $url URL that is about to be reformatted
+ * @return string reformatted link including HTML codes
+ */
+function style_url_for_mastodon($url) {
$styled_url = $url;
+ $parts = parse_url($url);
$scheme = $parts['scheme'].'://';
$styled_url = str_replace($scheme, '', $styled_url);
- $html = ''.
+ $html = ''.
'%s';
if (strlen($styled_url) > 30) {
@@ -203,7 +207,6 @@ function bb_style_url($match) {
}
}
-
function stripcode_br_cb($s) {
return '[code]' . str_replace('
', '', $s[1]) . '[/code]';
}