X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=5218a06e85a39e948f0261326d5fe613d44ffa5b;hb=63f66a5a93661cfc327449561a2150aa8187a228;hp=81f37ca04782aad0615084a9af9ab5564f0f2f0d;hpb=a9fb8e4d6052dbb5db95939128d491897b4f6a0c;p=friendica.git
diff --git a/include/bbcode.php b/include/bbcode.php
index 81f37ca047..5218a06e85 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -11,6 +11,7 @@ function stripcode_br_cb($s) {
function tryoembed($match){
$url = ((count($match)==2)?$match[1]:$match[2]);
+ logger("tryoembed: $url");
$o = oembed_fetch_url($url);
@@ -19,8 +20,7 @@ function tryoembed($match){
if ($o->type=="error") return $match[0];
$html = oembed_format_object($o);
-
- return $html;
+ return $html; //oembed_iframe($html,$o->width,$o->height);
}
@@ -31,6 +31,24 @@ function tryoembed($match){
function bbcode($Text,$preserve_nl = false) {
+
+ // Extract a single private image which uses data url's since preg has issues with
+ // large data sizes. Stash it away while we do bbcode conversion, and then put it back
+ // in after we've done all the regex matching. We cannot use any preg functions to do this.
+
+ $saved_image = '';
+ $img_start = strpos($Text,'[img]data:');
+ $img_end = strpos($Text,'[/img]');
+
+ if($img_start !== false && $img_end !== false && $img_end > $img_start) {
+ $start_fragment = substr($Text,0,$img_start);
+ $img_start += strlen('[img]');
+ $saved_image = substr($Text,$img_start,$img_end - $img_start);
+ $end_fragment = substr($Text,$img_end + strlen('[/img]'));
+// logger('saved_image: ' . $saved_image,LOGGER_DEBUG);
+ $Text = $start_fragment . '[$#saved_image#$]' . $end_fragment;
+ }
+
// If we find any event code, turn it into an event.
// After we're finished processing the bbcode we'll
// replace all of the event code with a reformatted version.
@@ -58,6 +76,7 @@ function bbcode($Text,$preserve_nl = false) {
// Perform URL Search
+
$Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1$2', $Text);
$Text = preg_replace_callback("/\[bookmark\=([^\]]*)\].*?\[\/bookmark\]/ism",'tryoembed',$Text);
@@ -95,12 +114,20 @@ function bbcode($Text,$preserve_nl = false) {
$Text = preg_replace("(\[size=(.*?)\](.*?)\[\/size\])ism","$2",$Text);
// Check for list text
- $Text = preg_replace("/\[list\](.*?)\[\/list\]/ism", '