1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Allow extension to "vouch" for raw HTML they produce

Rename "unsafeHtml" to "rawHtml"
This commit is contained in:
Aidan Woods
2018-03-15 19:46:03 +00:00
parent ef7ed7b66c
commit 3fc54bc966
4 changed files with 78 additions and 26 deletions

View File

@@ -1488,18 +1488,33 @@ class Parsedown
}
}
$unsafeHtml = false;
$permitRawHtml = false;
if (isset($Element['text']))
{
$text = $Element['text'];
}
// very strongly consider an alternative if you're writing an
// extension
elseif (isset($Element['unsafeHtml']))
elseif (isset($Element['rawHtml']))
{
$text = $Element['unsafeHtml'];
$text = $Element['rawHtml'];
$unsafeHtml = true;
$allowRawHtmlInSafeMode = false;
if (isset($Element['allowRawHtmlInSafeMode']))
{
$allowRawHtmlInSafeMode = (true === $Element['allowRawHtmlInSafeMode']);
}
if ($this->safeMode !== true)
{
$permitRawHtml = true;
}
elseif ($this->safeMode and $allowRawHtmlInSafeMode)
{
$permitRawHtml = true;
}
}
if (isset($text))
@@ -1515,7 +1530,7 @@ class Parsedown
{
$markup .= $this->{$Element['handler']}($text, $Element['nonNestables']);
}
elseif ($unsafeHtml !== true or $this->safeMode)
elseif ($permitRawHtml !== true)
{
$markup .= self::escape($text, true);
}