Merge pull request #7255 from annando/issue-7223
Issue 7223: Don't strip links
This commit is contained in:
commit
fa1f48e171
2 changed files with 10 additions and 16 deletions
|
@ -569,7 +569,7 @@ class BBCode extends BaseObject
|
||||||
}
|
}
|
||||||
|
|
||||||
$return = '';
|
$return = '';
|
||||||
if ($simplehtml == 7) {
|
if (in_array($simplehtml, [7, 9])) {
|
||||||
$return = self::convertUrlForOStatus($data["url"]);
|
$return = self::convertUrlForOStatus($data["url"]);
|
||||||
} elseif (($simplehtml != 4) && ($simplehtml != 0)) {
|
} elseif (($simplehtml != 4) && ($simplehtml != 0)) {
|
||||||
$return = sprintf('<a href="%s" target="_blank">%s</a><br>', $data["url"], $data["title"]);
|
$return = sprintf('<a href="%s" target="_blank">%s</a><br>', $data["url"], $data["title"]);
|
||||||
|
@ -985,16 +985,9 @@ class BBCode extends BaseObject
|
||||||
$text = ($is_quote_share? '<br />' : '') . '<p>' . html_entity_decode('♲ ', ENT_QUOTES, 'UTF-8') . ' ' . $author_contact['addr'] . ': </p>' . "\n" . $content;
|
$text = ($is_quote_share? '<br />' : '') . '<p>' . html_entity_decode('♲ ', ENT_QUOTES, 'UTF-8') . ' ' . $author_contact['addr'] . ': </p>' . "\n" . $content;
|
||||||
break;
|
break;
|
||||||
case 7: // statusnet/GNU Social
|
case 7: // statusnet/GNU Social
|
||||||
|
case 9: // ActivityPub
|
||||||
$text = ($is_quote_share? '<br />' : '') . '<p>' . html_entity_decode('♲ ', ENT_QUOTES, 'UTF-8') . ' @' . $author_contact['addr'] . ': ' . $content . '</p>' . "\n";
|
$text = ($is_quote_share? '<br />' : '') . '<p>' . html_entity_decode('♲ ', ENT_QUOTES, 'UTF-8') . ' @' . $author_contact['addr'] . ': ' . $content . '</p>' . "\n";
|
||||||
break;
|
break;
|
||||||
case 9: // Google+
|
|
||||||
$text = ($is_quote_share? '<br />' : '') . '<p>' . html_entity_decode('♲ ', ENT_QUOTES, 'UTF-8') . ' ' . $author_contact['addr'] . ': </p>' . "\n";
|
|
||||||
$text .= '<p>' . $content . '</p>' . "\n";
|
|
||||||
|
|
||||||
if ($attributes['link'] != '') {
|
|
||||||
$text .= '<p>' . $attributes['link'] . '</p>';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
// Transforms quoted tweets in rich attachments to avoid nested tweets
|
// Transforms quoted tweets in rich attachments to avoid nested tweets
|
||||||
if (stripos(Strings::normaliseLink($attributes['link']), 'http://twitter.com/') === 0 && OEmbed::isAllowedURL($attributes['link'])) {
|
if (stripos(Strings::normaliseLink($attributes['link']), 'http://twitter.com/') === 0 && OEmbed::isAllowedURL($attributes['link'])) {
|
||||||
|
@ -1146,13 +1139,14 @@ class BBCode extends BaseObject
|
||||||
* Simple HTML values meaning:
|
* Simple HTML values meaning:
|
||||||
* - 0: Friendica display
|
* - 0: Friendica display
|
||||||
* - 1: Unused
|
* - 1: Unused
|
||||||
* - 2: Used for Google+, Windows Phone push, Friendica API
|
* - 2: Used for Windows Phone push, Friendica API
|
||||||
* - 3: Used before converting to Markdown in bb2diaspora.php
|
* - 3: Used before converting to Markdown in bb2diaspora.php
|
||||||
* - 4: Used for WordPress, Libertree (before Markdown), pump.io and tumblr
|
* - 4: Used for WordPress, Libertree (before Markdown), pump.io and tumblr
|
||||||
* - 5: Unused
|
* - 5: Unused
|
||||||
* - 6: Unused
|
* - 6: Unused
|
||||||
* - 7: Used for dfrn, OStatus
|
* - 7: Used for dfrn, OStatus
|
||||||
* - 8: Used for WP backlink text setting
|
* - 8: Used for WP backlink text setting
|
||||||
|
* - 9: ActivityPub
|
||||||
*
|
*
|
||||||
* @param string $text
|
* @param string $text
|
||||||
* @param bool $try_oembed
|
* @param bool $try_oembed
|
||||||
|
@ -1298,7 +1292,7 @@ class BBCode extends BaseObject
|
||||||
// if the HTML is used to generate plain text, then don't do this search, but replace all URL of that kind to text
|
// if the HTML is used to generate plain text, then don't do this search, but replace all URL of that kind to text
|
||||||
if (!$for_plaintext) {
|
if (!$for_plaintext) {
|
||||||
$text = preg_replace(Strings::autoLinkRegEx(), '[url]$1[/url]', $text);
|
$text = preg_replace(Strings::autoLinkRegEx(), '[url]$1[/url]', $text);
|
||||||
if ($simple_html == 7) {
|
if (in_array($simple_html, [7, 9])) {
|
||||||
$text = preg_replace_callback("/\[url\]([$URLSearchString]*)\[\/url\]/ism", 'self::convertUrlForOStatusCallback', $text);
|
$text = preg_replace_callback("/\[url\]([$URLSearchString]*)\[\/url\]/ism", 'self::convertUrlForOStatusCallback', $text);
|
||||||
$text = preg_replace_callback("/\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[\/url\]/ism", 'self::convertUrlForOStatusCallback', $text);
|
$text = preg_replace_callback("/\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[\/url\]/ism", 'self::convertUrlForOStatusCallback', $text);
|
||||||
}
|
}
|
||||||
|
@ -1310,14 +1304,14 @@ class BBCode extends BaseObject
|
||||||
$text = str_replace(["\r","\n"], ['<br />', '<br />'], $text);
|
$text = str_replace(["\r","\n"], ['<br />', '<br />'], $text);
|
||||||
|
|
||||||
// Remove all hashtag addresses
|
// Remove all hashtag addresses
|
||||||
if ((!$try_oembed || $simple_html) && !in_array($simple_html, [3, 7])) {
|
if ((!$try_oembed || $simple_html) && !in_array($simple_html, [3, 7, 9])) {
|
||||||
$text = preg_replace("/([#@!])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $text);
|
$text = preg_replace("/([#@!])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $text);
|
||||||
} elseif ($simple_html == 3) {
|
} elseif ($simple_html == 3) {
|
||||||
// The ! is converted to @ since Diaspora only understands the @
|
// The ! is converted to @ since Diaspora only understands the @
|
||||||
$text = preg_replace("/([@!])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
|
$text = preg_replace("/([@!])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
|
||||||
'@<a href="$2">$3</a>',
|
'@<a href="$2">$3</a>',
|
||||||
$text);
|
$text);
|
||||||
} elseif ($simple_html == 7) {
|
} elseif (in_array($simple_html, [7, 9])) {
|
||||||
$text = preg_replace("/([@!])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
|
$text = preg_replace("/([@!])\[url\=([$URLSearchString]*)\](.*?)\[\/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>',
|
'$1<span class="vcard"><a href="$2" class="url u-url mention" title="$3"><span class="fn nickname mention">$3</span></a></span>',
|
||||||
$text);
|
$text);
|
||||||
|
@ -1333,7 +1327,7 @@ class BBCode extends BaseObject
|
||||||
$text = preg_replace("/#\[url\=[$URLSearchString]*\]\^\[\/url\]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/i",
|
$text = preg_replace("/#\[url\=[$URLSearchString]*\]\^\[\/url\]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/i",
|
||||||
"[bookmark=$1]$2[/bookmark]", $text);
|
"[bookmark=$1]$2[/bookmark]", $text);
|
||||||
|
|
||||||
if (in_array($simple_html, [2, 6, 7, 8, 9])) {
|
if (in_array($simple_html, [2, 6, 7, 8])) {
|
||||||
$text = preg_replace_callback("/([^#@!])\[url\=([^\]]*)\](.*?)\[\/url\]/ism", "self::expandLinksCallback", $text);
|
$text = preg_replace_callback("/([^#@!])\[url\=([^\]]*)\](.*?)\[\/url\]/ism", "self::expandLinksCallback", $text);
|
||||||
//$Text = preg_replace("/[^#@!]\[url\=([^\]]*)\](.*?)\[\/url\]/ism", ' $2 [url]$1[/url]', $Text);
|
//$Text = preg_replace("/[^#@!]\[url\=([^\]]*)\](.*?)\[\/url\]/ism", ' $2 [url]$1[/url]', $Text);
|
||||||
$text = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", ' $2 [url]$1[/url]',$text);
|
$text = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", ' $2 [url]$1[/url]',$text);
|
||||||
|
|
|
@ -1141,7 +1141,7 @@ class Transmitter
|
||||||
{
|
{
|
||||||
$event = [];
|
$event = [];
|
||||||
$event['name'] = $item['event-summary'];
|
$event['name'] = $item['event-summary'];
|
||||||
$event['content'] = BBCode::convert($item['event-desc'], false, 7);
|
$event['content'] = BBCode::convert($item['event-desc'], false, 9);
|
||||||
$event['startTime'] = DateTimeFormat::utc($item['event-start'] . '+00:00', DateTimeFormat::ATOM);
|
$event['startTime'] = DateTimeFormat::utc($item['event-start'] . '+00:00', DateTimeFormat::ATOM);
|
||||||
|
|
||||||
if (!$item['event-nofinish']) {
|
if (!$item['event-nofinish']) {
|
||||||
|
@ -1231,7 +1231,7 @@ class Transmitter
|
||||||
$regexp = "/[@!]\[url\=([^\[\]]*)\].*?\[\/url\]/ism";
|
$regexp = "/[@!]\[url\=([^\[\]]*)\].*?\[\/url\]/ism";
|
||||||
$body = preg_replace_callback($regexp, ['self', 'mentionCallback'], $body);
|
$body = preg_replace_callback($regexp, ['self', 'mentionCallback'], $body);
|
||||||
|
|
||||||
$data['content'] = BBCode::convert($body, false, 7);
|
$data['content'] = BBCode::convert($body, false, 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['source'] = ['content' => $item['body'], 'mediaType' => "text/bbcode"];
|
$data['source'] = ['content' => $item['body'], 'mediaType' => "text/bbcode"];
|
||||||
|
|
Loading…
Reference in a new issue