diff --git a/src/danog/MadelineProto/StrTools.php b/src/danog/MadelineProto/StrTools.php index 9314501e5..ec55c4159 100644 --- a/src/danog/MadelineProto/StrTools.php +++ b/src/danog/MadelineProto/StrTools.php @@ -158,7 +158,7 @@ abstract class StrTools extends Extension if ($markdown === '') { return $markdown; } - $html = (new Parsedown($markdown))->text($markdown); + $html = Parsedown::instance()->text($markdown); $document = new DOMDocument('', 'utf-8'); @$document->loadHTML(\mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8')); if (!$document->getElementsByTagName('body')[0]) { diff --git a/src/danog/MadelineProto/TL/Conversion/DOMEntities.php b/src/danog/MadelineProto/TL/Conversion/DOMEntities.php index 83c7e58e5..b470ec39f 100644 --- a/src/danog/MadelineProto/TL/Conversion/DOMEntities.php +++ b/src/danog/MadelineProto/TL/Conversion/DOMEntities.php @@ -24,7 +24,7 @@ final class DOMEntities { $dom = new \DOMDocument(); $html = \preg_replace("/\/i", "\n", $html); - $dom->loadxml("" . \str_replace(['&', ''', '"', '>', '<', '&'], ['&', '\'', "\"", '>', '<', '&'], \trim($html)) . ""); + $dom->loadxml("" . \trim($html) . ""); $this->parseNode($dom->getElementsByTagName('body')->item(0), 0); } /** diff --git a/tests/danog/MadelineProto/EntitiesTest.php b/tests/danog/MadelineProto/EntitiesTest.php index af44d50d2..4f25021bb 100644 --- a/tests/danog/MadelineProto/EntitiesTest.php +++ b/tests/danog/MadelineProto/EntitiesTest.php @@ -153,12 +153,12 @@ class EntitiesTest extends MadelineTestCase ], [ 'html', - '&\'"', - '&\'"', + '\'"', + '\'"', [ [ 'offset' => 0, - 'length' => 3, + 'length' => 2, 'type' => 'bold' ] ] @@ -182,6 +182,18 @@ class EntitiesTest extends MadelineTestCase ] ] ], + [ + 'markdown', + '_a b c <b> & " '_', + 'a b c & " \'', + [ + [ + 'offset' => 0, + 'length' => 15, + 'type' => 'italic', + ], + ] + ], [ 'markdown', 'test *italic* **bold** underlined ~~strikethrough~~
pre
code spoiler',