mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 12:59:46 +00:00
Fix parsers misbehaving with None text
This commit is contained in:
@@ -121,6 +121,9 @@ def parse(html):
|
||||
:param message: the message with HTML to be parsed.
|
||||
:return: a tuple consisting of (clean message, [message entities]).
|
||||
"""
|
||||
if not html:
|
||||
return html, []
|
||||
|
||||
parser = HTMLToTelegramParser()
|
||||
parser.feed(_add_surrogate(html))
|
||||
return _del_surrogate(parser.text), parser.entities
|
||||
@@ -135,7 +138,7 @@ def unparse(text, entities):
|
||||
:param entities: the MessageEntity's applied to the text.
|
||||
:return: a HTML representation of the combination of both inputs.
|
||||
"""
|
||||
if not entities:
|
||||
if not text or not entities:
|
||||
return text
|
||||
|
||||
text = _add_surrogate(text)
|
||||
|
Reference in New Issue
Block a user