diff --git a/src/Converter/TextConverter.php b/src/Converter/TextConverter.php index fcd4660..6236a1e 100644 --- a/src/Converter/TextConverter.php +++ b/src/Converter/TextConverter.php @@ -35,7 +35,7 @@ public function convert(ElementInterface $element) } } - return $markdown; + return htmlspecialchars($markdown, ENT_NOQUOTES, 'UTF-8'); } /** diff --git a/tests/HtmlConverterTest.php b/tests/HtmlConverterTest.php index 9c20e99..07c2f94 100644 --- a/tests/HtmlConverterTest.php +++ b/tests/HtmlConverterTest.php @@ -35,7 +35,7 @@ public function test_plain_text() $this->html_gives_markdown('
\ ` * _ { } [ ] ( ) > > # + - . !
', '\\\\ ` \* \_ { } \[ \] ( ) > > # + - . !'); + $this->html_gives_markdown('\ ` * _ { } [ ] ( ) > > # + - . !
', '\\\\ ` \* \_ { } \[ \] ( ) > > # + - . !'); } public function test_line_breaks() @@ -271,7 +271,7 @@ public function test_remove_nodes() public function test_html_entities() { - $this->html_gives_markdown('€
', '€'); + $this->html_gives_markdown('€
', '€'); $this->html_gives_markdown('<p>Some sample HTML</p>
', '`Some sample HTML
`'); } @@ -298,14 +298,14 @@ public function test_sanitization() $html = '<script type = "text/javascript"> function startTimer() { var tim = window.setTimeout("hideMessage()", 5000) } </head> <body>
';
$markdown = '```' . "\n" . '