From a99ebd42ec47ea531496f8ca5c07bf2868e21467 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 23 Nov 2017 15:21:50 -0800 Subject: change to bbcode calling parameters: important: will require pulling addons; also some extra checking of server headers in upload functions --- Zotlabs/Module/File_upload.php | 16 ++++++++++------ Zotlabs/Module/Wall_attach.php | 10 ++++++---- include/bbcode.php | 8 +++++--- include/markdown.php | 2 +- include/text.php | 4 ++-- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Zotlabs/Module/File_upload.php b/Zotlabs/Module/File_upload.php index e99118417..296dab708 100644 --- a/Zotlabs/Module/File_upload.php +++ b/Zotlabs/Module/File_upload.php @@ -30,8 +30,8 @@ class File_upload extends \Zotlabs\Web\Controller { $_REQUEST['allow_cid'] = perms2str($_REQUEST['contact_allow']); $_REQUEST['allow_gid'] = perms2str($_REQUEST['group_allow']); - $_REQUEST['deny_cid'] = perms2str($_REQUEST['contact_deny']); - $_REQUEST['deny_gid'] = perms2str($_REQUEST['group_deny']); + $_REQUEST['deny_cid'] = perms2str($_REQUEST['contact_deny']); + $_REQUEST['deny_gid'] = perms2str($_REQUEST['group_deny']); if($_REQUEST['filename']) { $r = attach_mkdir($channel, get_observer_hash(), $_REQUEST); @@ -51,10 +51,14 @@ class File_upload extends \Zotlabs\Web\Controller { $matches = []; $partial = false; - $x = preg_match('/bytes (\d*)\-(\d*)\/(\d*)/',$_SERVER['HTTP_CONTENT_RANGE'],$matches); - if($x) { - // logger('Content-Range: ' . print_r($matches,true)); - $partial = true; + + + if(array_key_exists('HTTP_CONTENT_RANGE',$_SERVER)) { + $pm = preg_match('/bytes (\d*)\-(\d*)\/(\d*)/',$_SERVER['HTTP_CONTENT_RANGE'],$matches); + if($pm) { + // logger('Content-Range: ' . print_r($matches,true)); + $partial = true; + } } if($partial) { diff --git a/Zotlabs/Module/Wall_attach.php b/Zotlabs/Module/Wall_attach.php index e001ad929..2250e6e44 100644 --- a/Zotlabs/Module/Wall_attach.php +++ b/Zotlabs/Module/Wall_attach.php @@ -41,10 +41,12 @@ class Wall_attach extends \Zotlabs\Web\Controller { $matches = []; $partial = false; - $x = preg_match('/bytes (\d*)\-(\d*)\/(\d*)/',$_SERVER['HTTP_CONTENT_RANGE'],$matches); - if($x) { - // logger('Content-Range: ' . print_r($matches,true)); - $partial = true; + if(array_key_exists('HTTP_CONTENT_RANGE',$_SERVER)) { + $pm = preg_match('/bytes (\d*)\-(\d*)\/(\d*)/',$_SERVER['HTTP_CONTENT_RANGE'],$matches); + if($pm) { + // logger('Content-Range: ' . print_r($matches,true)); + $partial = true; + } } if($partial) { diff --git a/include/bbcode.php b/include/bbcode.php index 7ebc8d37c..fd476766e 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -707,10 +707,12 @@ function parseIdentityAwareHTML($Text) { return $Text; } - // BBcode 2 HTML was written by WAY2WEB.net - // extended to work with Mistpark/Friendica/Redmatrix/Hubzilla - Mike Macgirvin -function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) { +function bbcode($Text, $options = []) { + + $preserve_nl = ((array_key_exists('preserve_nl',$options)) ? $options['preserve_nl'] : false); + $tryoembed = ((array_key_exists('tryomebed',$options)) ? $options['tryoembed'] : true); + $cache = ((array_key_exists('cache',$options)) ? $options['cache'] : false); call_hooks('bbcode_filter', $Text); diff --git a/include/markdown.php b/include/markdown.php index f398d279e..e4a35e3c3 100644 --- a/include/markdown.php +++ b/include/markdown.php @@ -204,7 +204,7 @@ function bb_to_markdown($Text, $options = []) { $Text = $x['bbcode']; // Convert it to HTML - don't try oembed - $Text = bbcode($Text, $preserve_nl, false); + $Text = bbcode($Text, [ 'tryoembed' => false ]); // Markdownify does not preserve previously escaped html entities such as <> and &. $Text = str_replace(array('<','>','&'),array('&_lt_;','&_gt_;','&_amp_;'),$Text); diff --git a/include/text.php b/include/text.php index 343e3f00b..f3d522e04 100644 --- a/include/text.php +++ b/include/text.php @@ -1679,9 +1679,9 @@ function prepare_text($text, $content_type = 'text/bbcode', $cache = false) { require_once('include/bbcode.php'); if(stristr($text,'[nosmile]')) - $s = bbcode($text,false,true,$cache); + $s = bbcode($text, [ 'cache' => $cache ]); else - $s = smilies(bbcode($text,false,true,$cache)); + $s = smilies(bbcode($text, [ 'cache' => $cache ])); $s = zidify_links($s); -- cgit v1.2.3