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

Still grab the text if safe mode enabled, but output it escaped

This commit is contained in:
Aidan Woods 2018-03-15 11:09:55 +00:00
parent e4c5be026d
commit ef7ed7b66c
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
2 changed files with 8 additions and 1 deletions

View File

@ -1495,9 +1495,10 @@ class Parsedown
}
// very strongly consider an alternative if you're writing an
// extension
elseif (isset($Element['unsafeHtml']) and !$this->safeMode)
elseif (isset($Element['unsafeHtml']))
{
$text = $Element['unsafeHtml'];
$unsafeHtml = true;
}

View File

@ -60,11 +60,17 @@ class ParsedownTest extends TestCase
{
$markdown = "```php\nfoobar\n```";
$expectedMarkup = '<pre><code class="language-php"><p>foobar</p></code></pre>';
$expectedSafeMarkup = '<pre><code class="language-php">&lt;p&gt;foobar&lt;/p&gt;</code></pre>';
$unsafeExtension = new UnsafeExtension;
$actualMarkup = $unsafeExtension->text($markdown);
$this->assertEquals($expectedMarkup, $actualMarkup);
$unsafeExtension->setSafeMode(true);
$actualSafeMarkup = $unsafeExtension->text($markdown);
$this->assertEquals($expectedSafeMarkup, $actualSafeMarkup);
}
function data()