aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-03-14 17:07:29 -0700
committerzotlabs <mike@macgirvin.com>2017-03-14 17:07:29 -0700
commit2c73b457ef0943d46804480a0aa016f64c11edbf (patch)
tree330baac97f28e61a3e8daed75e5736fdaae7a28c /include/text.php
parent2f5f1a4d641c5873c308d6ab58ae239f2758e1e4 (diff)
downloadvolse-hubzilla-2c73b457ef0943d46804480a0aa016f64c11edbf.tar.gz
volse-hubzilla-2c73b457ef0943d46804480a0aa016f64c11edbf.tar.bz2
volse-hubzilla-2c73b457ef0943d46804480a0aa016f64c11edbf.zip
input filter updates
Diffstat (limited to 'include/text.php')
-rw-r--r--include/text.php18
1 files changed, 11 insertions, 7 deletions
diff --git a/include/text.php b/include/text.php
index 6715eca22..500c87ad5 100644
--- a/include/text.php
+++ b/include/text.php
@@ -3,6 +3,7 @@
* @file include/text.php
*/
+use \Zotlabs\Lib as Zlib;
use \Michelf\MarkdownExtra;
require_once("include/bbcode.php");
@@ -89,12 +90,10 @@ function escape_tags($string) {
}
-function z_input_filter($channel_id,$s,$type = 'text/bbcode') {
+function z_input_filter($s,$type = 'text/bbcode',$allow_code = false) {
if($type === 'text/bbcode')
return escape_tags($s);
- if($type === 'text/markdown')
- return escape_tags($s);
if($type == 'text/plain')
return escape_tags($s);
if($type == 'application/x-pdl')
@@ -104,13 +103,17 @@ function z_input_filter($channel_id,$s,$type = 'text/bbcode') {
return $s;
}
- $r = q("select channel_pageflags from channel where channel_id = %d limit 1",
- intval($channel_id)
- );
- if(($r) && (local_channel() == $channel_id) && ($r[0]['channel_pageflags'] & PAGE_ALLOWCODE)) {
+ if($allow_code) {
+ if($type === 'text/markdown')
+ return htmlspecialchars($s,ENT_QUOTES);
return $s;
}
+ if($type === 'text/markdown') {
+ $x = new Zlib\MarkdownSoap($s);
+ return $x->clean();
+ }
+
if($type === 'text/html')
return purify_html($s);
@@ -1636,6 +1639,7 @@ function prepare_text($text, $content_type = 'text/bbcode', $cache = false) {
break;
case 'text/markdown':
+ $text = Zlib\MarkdownSoap::unescape($text);
$s = MarkdownExtra::defaultTransform($text);
break;