Offload html escaping from editor to parsedown

This commit is contained in:
Starbeamrainbowlabs 2016-04-08 21:05:42 +01:00
parent 2afb044672
commit b044651dc3
4 changed files with 18 additions and 2 deletions

View File

@ -3318,6 +3318,8 @@ register_module([
// Read in the new page content
$pagedata = $_POST["content"];
/*** Note needed anymore as Parsedown has an option that does ***
*** this for us, and is _way_ more intelligent about it. ***
// Santise it if necessary
if($settings->clean_raw_html)
{
@ -3327,6 +3329,7 @@ register_module([
// the less than sign ('<') that is used to open HTML tags.
$pagedata = str_replace("&gt;", ">", $pagedata);
}
***/
// Read in the new page tags, so long as there are actually some tags to read in
$page_tags = [];
@ -4155,6 +4158,11 @@ register_module([
$parser = new PeppermintParsedown();
$parser->setInternalLinkBase("?page=%s");
add_parser("parsedown", function($source) use ($parser) {
global $settings;
if($settings->clean_raw_html)
$parser->setMarkupEscaped(true);
else
$parser->setMarkupEscaped(false);
$result = $parser->text($source);
return $result;

View File

@ -104,7 +104,7 @@
"author": "Starbeamrainbowlabs",
"description": "Allows you to edit pages by adding the edit and save actions. You should probably include this one.",
"id": "page-edit",
"lastupdate": 1460142693,
"lastupdate": 1460145881,
"optional": false
},
{
@ -194,7 +194,7 @@
"author": "Emanuil Rusev & Starbeamrainbowlabs",
"description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds a some weight to your installation, and also *requires* write access to the disk on first load.",
"id": "parser-parsedown",
"lastupdate": 1460137501,
"lastupdate": 1460145045,
"optional": false
}
]

View File

@ -123,6 +123,8 @@ register_module([
// Read in the new page content
$pagedata = $_POST["content"];
/*** Note needed anymore as Parsedown has an option that does ***
*** this for us, and is _way_ more intelligent about it. ***
// Santise it if necessary
if($settings->clean_raw_html)
{
@ -132,6 +134,7 @@ register_module([
// the less than sign ('<') that is used to open HTML tags.
$pagedata = str_replace("&gt;", ">", $pagedata);
}
***/
// Read in the new page tags, so long as there are actually some tags to read in
$page_tags = [];

View File

@ -11,6 +11,11 @@ register_module([
$parser = new PeppermintParsedown();
$parser->setInternalLinkBase("?page=%s");
add_parser("parsedown", function($source) use ($parser) {
global $settings;
if($settings->clean_raw_html)
$parser->setMarkupEscaped(true);
else
$parser->setMarkupEscaped(false);
$result = $parser->text($source);
return $result;