php-markdown icon indicating copy to clipboard operation
php-markdown copied to clipboard

Encoding problems and no_entities

Open markseuffert opened this issue 9 years ago • 4 comments

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>&amp;lt;script></strong></p>
Input: [text<text](link)
Output: <p><a href="link">text&amp;lt;text</a></p>

It doesn't happen when using no_markup = true only.

markseuffert avatar Aug 25 '14 20:08 markseuffert

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;amp; bar</strong></p>

However I would expect:

<p><strong>foo &amp; bar</strong></p>

jdufresne avatar Dec 02 '14 15:12 jdufresne

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.

michelf avatar Dec 02 '14 15:12 michelf

We don't use no_entities = true anymore, no encoding problems without it.

markseuffert avatar Oct 21 '15 14:10 markseuffert

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.

michelf avatar Oct 21 '15 15:10 michelf