2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-28 12:57:52 +00:00

Escape text inside entity when building unparsed text (#1156)

This commit is contained in:
Andrea Princic 2022-12-06 20:09:31 +01:00 committed by GitHub
parent fd2819ca7f
commit 669b39927b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -233,8 +233,10 @@ class HTML:
while i < len(entities):
i += recursive(i)
last_offset = entities_offsets[-1][1]
# no need to sort, but still add entities starting from the end
for entity, offset in reversed(entities_offsets):
text = text[:offset] + entity + text[offset:]
text = text[:offset] + entity + html.escape(text[offset:last_offset]) + text[last_offset:]
last_offset = offset
return utils.remove_surrogates(text)