diff options
-rw-r--r-- | Zotlabs/Module/Item.php | 9 | ||||
-rw-r--r-- | include/wiki.php | 28 |
2 files changed, 30 insertions, 7 deletions
diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index bebe5e89b..7f2813076 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -21,6 +21,7 @@ require_once('include/crypto.php'); require_once('include/items.php'); require_once('include/attach.php'); require_once('include/bbcode.php'); +require_once('include/security.php'); use \Zotlabs\Lib as Zlib; @@ -34,9 +35,7 @@ class Item extends \Zotlabs\Web\Controller { if((! local_channel()) && (! remote_channel()) && (! x($_REQUEST,'commenter'))) return; - - require_once('include/security.php'); - + $uid = local_channel(); $channel = null; $observer = null; @@ -1036,9 +1035,7 @@ class Item extends \Zotlabs\Web\Controller { if((! local_channel()) && (! remote_channel())) return; - - require_once('include/security.php'); - + if((argc() == 3) && (argv(1) === 'drop') && intval(argv(2))) { require_once('include/items.php'); diff --git a/include/wiki.php b/include/wiki.php index 332d4efe0..922be6924 100644 --- a/include/wiki.php +++ b/include/wiki.php @@ -332,9 +332,35 @@ function wiki_page_history($arr) { } } +function wiki_prepare_content($s) { + + $text = preg_replace_callback('{ + (?:\n\n|\A\n?) + ( # $1 = the code block -- one or more lines, starting with a space/tab + (?> + [ ]{'.'4'.'} # Lines must start with a tab or a tab-width of spaces + .*\n+ + )+ + ) + ((?=^[ ]{0,'.'4'.'}\S)|\Z) # Lookahead for non-space at line-start, or end of doc + }xm', + 'wiki_prepare_content_callback', $s); + + return $text; +} + +function wiki_prepare_content_callback($matches) { + $codeblock = $matches[1]; + + $codeblock = htmlspecialchars($codeblock, ENT_NOQUOTES, UTF8, false); + return "\n\n" . $codeblock ; +} + + + function wiki_save_page($arr) { $pageUrlName = ((array_key_exists('pageUrlName',$arr)) ? $arr['pageUrlName'] : ''); - $content = ((array_key_exists('content',$arr)) ? purify_html($arr['content']) : ''); + $content = ((array_key_exists('content',$arr)) ? purify_html(wiki_prepare_content($arr['content'])) : ''); $resource_id = ((array_key_exists('resource_id',$arr)) ? $arr['resource_id'] : ''); $w = wiki_get_wiki($resource_id); if (!$w['path']) { |