From 699fe60e5072eeffebfb2f3b9b85cefe6dd1b7bc Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Thu, 22 Jan 2015 17:43:45 +0100 Subject: [PATCH] [fix] handle single closing element in HTMLTextExtractor --- searx/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/searx/utils.py b/searx/utils.py index 89128d506..f15f8a4bc 100644 --- a/searx/utils.py +++ b/searx/utils.py @@ -82,8 +82,12 @@ class HTMLTextExtractor(HTMLParser): self.tags.append(tag) def handle_endtag(self, tag): + if not self.tags: + return + if tag != self.tags[-1]: raise Exception("invalid html") + self.tags.pop() def is_valid_tag(self):