php-markdown
php-markdown copied to clipboard
Encoding problems and no_entities
Hi,
I was testing how to prevent HTML code in generated output, together with @wunderfeyd. Looks like there's a double encoding when using no_markup = true
and no_entities = true
.
Input: **<script>**
Output: <p><strong>&lt;script></strong></p>
Input: [text<text](link)
Output: <p><a href="link">text&lt;text</a></p>
It doesn't happen when using no_markup = true
only.
I recently hit this same issue: Using the test script:
$my_text = '**foo & bar**';
$parser = new \Michelf\Markdown();
$parser->no_markup = true;
$parser->no_entities = true;
$my_html = $parser->transform($my_text);
echo $my_html;
This outputs:
<p><strong>foo &amp; bar</strong></p>
However I would expect:
<p><strong>foo & bar</strong></p>
Indeed, that shouldn't happen. I'll get down to it eventually, but I'd also be happy to accept a pull request.
Maintaining those two modes is somewhat cumbersome given there's no way to test the non-defaut mode in MDTest.
We don't use no_entities = true
anymore, no encoding problems without it.
I guess it's fixed in Yellow, but this issue about double-encoding is still present in PHP Markdown when no_entities = true
, and is still worth fixing. So I'll keep it open.