aboutsummaryrefslogtreecommitdiffstats
path: root/include/wiki.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2016-12-27 15:26:47 -0800
committerzotlabs <mike@macgirvin.com>2016-12-27 15:26:47 -0800
commit17b7042a25da00e1e553b719001fdcabdad8a103 (patch)
tree52af79fff98de61676478487249e657fb420ef99 /include/wiki.php
parent286c3eafe365c80022602696621c604760ecc8c5 (diff)
downloadvolse-hubzilla-17b7042a25da00e1e553b719001fdcabdad8a103.tar.gz
volse-hubzilla-17b7042a25da00e1e553b719001fdcabdad8a103.tar.bz2
volse-hubzilla-17b7042a25da00e1e553b719001fdcabdad8a103.zip
issue with HTML in code blocks in markdown in wiki
Diffstat (limited to 'include/wiki.php')
-rw-r--r--include/wiki.php28
1 files changed, 27 insertions, 1 deletions
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']) {