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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user