Bugfixes to html parsing
This commit is contained in:
parent
85b1345ad9
commit
12e8f1c050
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
"repositories": [
|
"repositories": [
|
||||||
{
|
{
|
||||||
"type": "vcs",
|
"type": "git",
|
||||||
"url": "https://github.com/danog/phpseclib"
|
"url": "https://github.com/danog/phpseclib"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -225,7 +225,9 @@ trait TL
|
|||||||
|
|
||||||
return \danog\PHP\Struct::pack('<i', $tl['id']).$this->serialize_params($tl, $arguments);
|
return \danog\PHP\Struct::pack('<i', $tl['id']).$this->serialize_params($tl, $arguments);
|
||||||
}
|
}
|
||||||
|
public function html_entity_decode($stuff) {
|
||||||
|
return html_entity_decode(str_replace('<br />', "\n", $stuff));
|
||||||
|
}
|
||||||
public function serialize_params($tl, $arguments)
|
public function serialize_params($tl, $arguments)
|
||||||
{
|
{
|
||||||
$serialized = '';
|
$serialized = '';
|
||||||
@ -249,26 +251,26 @@ trait TL
|
|||||||
|
|
||||||
case 'b':
|
case 'b':
|
||||||
case 'strong':
|
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)];
|
$arguments['entities'][] = ['_' => 'messageEntityBold', 'offset' => mb_strlen($nmessage), 'length' => mb_strlen($text)];
|
||||||
$nmessage .= $text;
|
$nmessage .= $text;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
case 'em':
|
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)];
|
$arguments['entities'][] = ['_' => 'messageEntityItalic', 'offset' => mb_strlen($nmessage), 'length' => mb_strlen($text)];
|
||||||
$nmessage .= $text;
|
$nmessage .= $text;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'code':
|
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)];
|
$arguments['entities'][] = ['_' => 'messageEntityCode', 'offset' => mb_strlen($nmessage), 'length' => mb_strlen($text)];
|
||||||
$nmessage .= $text;
|
$nmessage .= $text;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'pre':
|
case 'pre':
|
||||||
$text = html_entity_decode($tag->innerHtml);
|
$text = $this->html_entity_decode($tag->innerHtml);
|
||||||
$language = $tag->getAttribute('language');
|
$language = $tag->getAttribute('language');
|
||||||
if ($language === null) {
|
if ($language === null) {
|
||||||
$language = '';
|
$language = '';
|
||||||
@ -278,7 +280,7 @@ trait TL
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'a':
|
case 'a':
|
||||||
$text = html_entity_decode($tag->innerHtml);
|
$text = $this->html_entity_decode($tag->innerHtml);
|
||||||
$href = $tag->getAttribute('href');
|
$href = $tag->getAttribute('href');
|
||||||
if (preg_match('|mention:|', $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']];
|
$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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$nmessage .= html_entity_decode($tag->outerHtml);
|
$nmessage .= $this->html_entity_decode($tag->outerHtml);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user