-
Notifications
You must be signed in to change notification settings - Fork 443
Closed
Labels
Description
Describe the bug
Converting a string containing an unclosed <!-- tag with safe_mode='escape' does not replace < with <. This causes the whole html document to be commented out when attempting to render.
There's also something odd about how markdown is being rendered inside of comments
To Reproduce
>>> markdown2.markdown('*foo* <!-- *bar* -->', safe_mode='escape') # with closing tag, OK
'<p><em>foo</em> <!-- *bar* --></p>\n'
>>> markdown2.markdown('*foo* <!-- *bar*', safe_mode='escape') # without closing tag, bad
'<p><em>foo</em> <!-- <em>bar</em></p>\n'Expected behavior
<!-- should always be replaced with <!--.
It's also inconsistent whether it puts <em> tags around the 'commented' section. I believe it should be replacing it in both cases:
>>> markdown2.markdown('*foo* <!-- *bar* -->', safe_mode='escape')
'<p><em>foo</em> <!-- <em>bar</em> --></p>\n'
>>> markdown2.markdown('*foo* <!-- *bar*', safe_mode='escape')
'<p><em>foo</em> <!-- <em>bar</em></p>\n'Debug info
Version of library being used: 2.4.12
Any extras being used: None