aboutsummaryrefslogtreecommitdiffstats
path: root/include/bbcode.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2011-11-27 04:09:14 -0800
committerfriendica <info@friendica.com>2011-11-27 04:09:14 -0800
commitcf7568efd72e93f1807c8560b78cae2580667413 (patch)
tree6b8af40094a08cfcd0b598afe1328f148d8c20de /include/bbcode.php
parent0f4a42f550b5bc863cec7c7a3fca26a028599dcc (diff)
downloadvolse-hubzilla-cf7568efd72e93f1807c8560b78cae2580667413.tar.gz
volse-hubzilla-cf7568efd72e93f1807c8560b78cae2580667413.tar.bz2
volse-hubzilla-cf7568efd72e93f1807c8560b78cae2580667413.zip
extract private images before bbcode translation since preg has issues with large data sizes.
Diffstat (limited to 'include/bbcode.php')
-rw-r--r--include/bbcode.php22
1 files changed, 21 insertions, 1 deletions
diff --git a/include/bbcode.php b/include/bbcode.php
index 06a610173..71745de58 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -30,6 +30,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. Put it back in after we've done all the regex matching.
+
+ $saved_image = '';
+ $img_start = strpos($Text,'[img]data:');
+ if($img_start !== false) {
+ $start_fragment = substr($Text,0,$img_start);
+ $img_start += strlen('[img]');
+ $saved_image = substr($Text,$img_start);
+ $img_end = strpos($saved_image,'[/img]');
+ $saved_image = substr($saved_image,0,$img_end);
+ logger('saved_image: ' . $saved_image);
+ $img_end += strlen('[/img]');
+ $Text = $start_fragment . '[$#saved_image#$]' . substr($Text,strlen($start_fragment) + strlen('[img]') + $img_end);
+
+ }
+
// 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.
@@ -206,7 +224,9 @@ function bbcode($Text,$preserve_nl = false) {
// fix any escaped ampersands that may have been converted into links
$Text = preg_replace("/\<(.*?)(src|href)=(.*?)\&amp\;(.*?)\>/ism",'<$1$2=$3&$4>',$Text);
-
+ if(strlen($saved_image))
+ $Text = str_replace('[$#saved_image#$]','<img src="' . $saved_image .'" alt="' . t('Image/photo') . '" />',$Text);
+
call_hooks('bbcode',$Text);
return $Text;