X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=df883eed64aa79e100476252149edf4b50ad0011;hb=bae725c2797fcae0d61c13822d27e4277ec0cc0e;hp=a6ffc39c18744c4dd999d994766aede3ae4c1841;hpb=26b335ef3d8b1ec4e1b4e22cd7d3c34e66d2549d;p=friendica.git
diff --git a/include/bbcode.php b/include/bbcode.php
index a6ffc39c18..df883eed64 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -1,9 +1,13 @@
', $newbody);
+ $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '', $newbody);
$cnt++;
}
@@ -548,7 +552,7 @@ function bb_ShareAttributes($share, $simplehtml)
break;
case 4:
$headline .= '
' . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8');
- $headline .= t('%2$s %3$s', $link, $userid, $posted);
+ $headline .= L10n::t('%2$s %3$s', $link, $userid, $posted);
$headline .= ":
";
$text = trim($share[1]);
@@ -968,12 +972,12 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
// 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 (!$forplaintext) {
- // Autolink feature
- if ($simplehtml != 7) {
- $Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@]+)/ism", '$1$2', $Text);
- } else {
- $Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@]+)/ism", '$1[url]$2[/url]', $Text);
-
+ // Autolink feature (thanks to http://code.seebz.net/p/autolink-php/)
+ // Currently disabled, since the function is too greedy
+ // $autolink_regex = "`([^\]\=\"']|^)(https?\://[^\s<]+[^\s<\.\)])`ism";
+ $autolink_regex = "/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism";
+ $Text = preg_replace($autolink_regex, '$1[url]$2[/url]', $Text);
+ if ($simplehtml == 7) {
$Text = preg_replace_callback("/\[url\]([$URLSearchString]*)\[\/url\]/ism", 'bb_style_url', $Text);
$Text = preg_replace_callback("/\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[\/url\]/ism", 'bb_style_url', $Text);
}
@@ -1044,10 +1048,6 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
$expression = "=diaspora://.*?/post/([0-9A-Za-z\-_@.:]{15,254}[0-9A-Za-z])=ism";
$Text = preg_replace($expression, System::baseUrl()."/display/$1", $Text);
- if ($tryoembed) {
- $Text = preg_replace_callback("/\[url\]([$URLSearchString]*)\[\/url\]/ism", $tryoembed_callback, $Text);
- }
-
$Text = preg_replace("/([#])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
'$1$3', $Text);
@@ -1183,7 +1183,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
// Check for [spoiler=Author] text
- $t_wrote = t('$1 wrote:');
+ $t_wrote = L10n::t('$1 wrote:');
// handle nested quotes
$endlessloop = 0;
@@ -1205,7 +1205,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
// Check for [quote=Author] text
- $t_wrote = t('$1 wrote:');
+ $t_wrote = L10n::t('$1 wrote:');
// handle nested quotes
$endlessloop = 0;
@@ -1226,8 +1226,8 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
// [img]pathtoimage[/img]
$Text = preg_replace_callback("/\[img\](.*?)\[\/img\]/ism", 'bb_PictureCache', $Text);
- $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '', $Text);
- $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '', $Text);
+ $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '', $Text);
+ $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '', $Text);
// Shared content
$Text = preg_replace_callback("/(.*?)\[share(.*?)\](.*?)\[\/share\]/ism",
@@ -1235,9 +1235,9 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
return bb_ShareAttributes($match, $simplehtml);
}, $Text);
- $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism", '
', $Text);
- $Text = preg_replace("/\[crypt(.*?)\](.*?)\[\/crypt\]/ism", '
', $Text);
- //$Text = preg_replace("/\[crypt=(.*?)\](.*?)\[\/crypt\]/ism", '
', $Text);
+ $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism", '
', $Text);
+ $Text = preg_replace("/\[crypt(.*?)\](.*?)\[\/crypt\]/ism", '
', $Text);
+ //$Text = preg_replace("/\[crypt=(.*?)\](.*?)\[\/crypt\]/ism", '
', $Text);
// Try to Oembed
if ($tryoembed) {
@@ -1355,7 +1355,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
// sanitizes src attributes (http and redir URLs for displaying in a web page, cid used for inline images in emails)
static $allowed_src_protocols = ['http', 'redir', 'cid'];
$Text = preg_replace('#<([^>]*?)(src)="(?!' . implode('|', $allowed_src_protocols) . ')(.*?)"(.*?)>#ism',
- '<$1$2=""$4 data-original-src="$3" class="invalid-src" title="' . t('Invalid source protocol') . '">', $Text);
+ '<$1$2=""$4 data-original-src="$3" class="invalid-src" title="' . L10n::t('Invalid source protocol') . '">', $Text);
// sanitize href attributes (only whitelisted protocols URLs)
// default value for backward compatibility
@@ -1366,7 +1366,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
$allowed_link_protocols[] = 'redir/';
$regex = '#<([^>]*?)(href)="(?!' . implode('|', $allowed_link_protocols) . ')(.*?)"(.*?)>#ism';
- $Text = preg_replace($regex, '<$1$2="javascript:void(0)"$4 data-original-href="$3" class="invalid-href" title="' . t('Invalid link protocol') . '">', $Text);
+ $Text = preg_replace($regex, '<$1$2="javascript:void(0)"$4 data-original-href="$3" class="invalid-href" title="' . L10n::t('Invalid link protocol') . '">', $Text);
if ($saved_image) {
$Text = bb_replace_images($Text, $saved_image);
@@ -1400,7 +1400,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
//$Text = str_replace('