From 12e8f1c050298ea631fa5f776061a7686acf8457 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Mon, 13 Feb 2017 15:14:37 +0100 Subject: [PATCH] Bugfixes to html parsing --- composer.json | 2 +- src/danog/MadelineProto/TL/TL.php | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 1263e107d..9520b9c30 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "repositories": [ { - "type": "vcs", + "type": "git", "url": "https://github.com/danog/phpseclib" } ], diff --git a/src/danog/MadelineProto/TL/TL.php b/src/danog/MadelineProto/TL/TL.php index 5f82d6a35..db4da82a6 100644 --- a/src/danog/MadelineProto/TL/TL.php +++ b/src/danog/MadelineProto/TL/TL.php @@ -225,7 +225,9 @@ trait TL return \danog\PHP\Struct::pack('serialize_params($tl, $arguments); } - + public function html_entity_decode($stuff) { + return html_entity_decode(str_replace('
', "\n", $stuff)); + } public function serialize_params($tl, $arguments) { $serialized = ''; @@ -249,26 +251,26 @@ trait TL case 'b': case 'strong': - $text = html_entity_decode($tag->innerHtml); + $text = $this->html_entity_decode($tag->innerHtml); $arguments['entities'][] = ['_' => 'messageEntityBold', 'offset' => mb_strlen($nmessage), 'length' => mb_strlen($text)]; $nmessage .= $text; break; case 'i': case 'em': - $text = html_entity_decode($tag->innerHtml); + $text = $this->html_entity_decode($tag->innerHtml); $arguments['entities'][] = ['_' => 'messageEntityItalic', 'offset' => mb_strlen($nmessage), 'length' => mb_strlen($text)]; $nmessage .= $text; break; case 'code': - $text = html_entity_decode($tag->innerHtml); + $text = $this->html_entity_decode($tag->innerHtml); $arguments['entities'][] = ['_' => 'messageEntityCode', 'offset' => mb_strlen($nmessage), 'length' => mb_strlen($text)]; $nmessage .= $text; break; case 'pre': - $text = html_entity_decode($tag->innerHtml); + $text = $this->html_entity_decode($tag->innerHtml); $language = $tag->getAttribute('language'); if ($language === null) { $language = ''; @@ -278,7 +280,7 @@ trait TL break; case 'a': - $text = html_entity_decode($tag->innerHtml); + $text = $this->html_entity_decode($tag->innerHtml); $href = $tag->getAttribute('href'); if (preg_match('|mention:|', $href)) { $arguments['entities'][] = ['_' => 'inputMessageEntityMentionName', 'offset' => mb_strlen($nmessage), 'length' => mb_strlen($text), 'user_id' => $this->get_info(str_replace('mention:', '', $href))['InputUser']]; @@ -289,7 +291,7 @@ trait TL break; default: - $nmessage .= html_entity_decode($tag->outerHtml); + $nmessage .= $this->html_entity_decode($tag->outerHtml); break; } }