X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fbbcode.php;h=6b733c8f43150689e4c68c6034ae89da441e6c1f;hb=a9670cbb7d2cab644ee9d499aade98164f92631a;hp=e20b2478d3012927a491f47b465a21ee2c2d5a0f;hpb=1a7badb40518538c79ecff6186eb3d996734760e;p=friendica.git
diff --git a/include/bbcode.php b/include/bbcode.php
index e20b2478d3..6b733c8f43 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,17 +20,35 @@ function tryoembed($match){
if ($o->type=="error") return $match[0];
$html = oembed_format_object($o);
- return oembed_iframe($html,$o->width,$o->height);
+ return $html; //oembed_iframe($html,$o->width,$o->height);
}
// BBcode 2 HTML was written by WAY2WEB.net
- // extended to work with Mistpark/Friendika - Mike Macgirvin
+ // extended to work with Mistpark/Friendica - Mike Macgirvin
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.
@@ -57,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);
@@ -94,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", '