From 8cdcf90b1044a07b5618d99e13111aed27e28b7d Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 28 Jul 2019 15:11:18 +0200 Subject: [PATCH] Enhance Parser when dealing with leading and trailing whitespaces --- pyrogram/client/parser/html.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyrogram/client/parser/html.py b/pyrogram/client/parser/html.py index 9aff757f..41efe3b3 100644 --- a/pyrogram/client/parser/html.py +++ b/pyrogram/client/parser/html.py @@ -86,7 +86,8 @@ class Parser(HTMLParser): for entities in self.tag_entities.values(): for entity in entities: - entity.length += len(data) + entity.offset += len(data) - len(data.lstrip()) # Ignore left whitespaces for offsets + entity.length += len(data.strip()) # Ignore all whitespaces (left + right) for lengths self.text += data