From c7888437e881d6188c710fe405f0ae8334755611 Mon Sep 17 00:00:00 2001 From: Andrea Princic <48788808+Princic-1837592@users.noreply.github.com> Date: Sat, 29 Jan 2022 18:50:51 +0100 Subject: [PATCH] Fixed error while unparsing consecutive entities (#885) --- pyrogram/parser/html.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pyrogram/parser/html.py b/pyrogram/parser/html.py index b70a189f..81c761ac 100644 --- a/pyrogram/parser/html.py +++ b/pyrogram/parser/html.py @@ -175,10 +175,7 @@ class HTML: entities_offsets.append((start_tag, start,)) entities_offsets.append((end_tag, end,)) - # sorting by offset (desc) - entities_offsets.sort(key=lambda x: -x[1]) - - for entity, offset in entities_offsets: + for entity, offset in reversed(entities_offsets): text = text[:offset] + entity + text[offset:] return utils.remove_surrogates(text)