Skip to content

Commit 669b399

Browse files
Escape text inside entity when building unparsed text (pyrogram#1156)
1 parent fd2819c commit 669b399

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

pyrogram/parser/html.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,10 @@ def recursive(entity_i: int) -> int:
233233
while i < len(entities):
234234
i += recursive(i)
235235

236+
last_offset = entities_offsets[-1][1]
236237
# no need to sort, but still add entities starting from the end
237238
for entity, offset in reversed(entities_offsets):
238-
text = text[:offset] + entity + text[offset:]
239+
text = text[:offset] + entity + html.escape(text[offset:last_offset]) + text[last_offset:]
240+
last_offset = offset
239241

240242
return utils.remove_surrogates(text)

0 commit comments

Comments
 (0)