Browse Source

[fix] handle single closing element in HTMLTextExtractor

Adam Tauber 10 years ago
parent
commit
699fe60e50
1 changed files with 4 additions and 0 deletions
  1. 4 0
      searx/utils.py

+ 4 - 0
searx/utils.py

@@ -82,8 +82,12 @@ class HTMLTextExtractor(HTMLParser):
         self.tags.append(tag)
         self.tags.append(tag)
 
 
     def handle_endtag(self, tag):
     def handle_endtag(self, tag):
+        if not self.tags:
+            return
+
         if tag != self.tags[-1]:
         if tag != self.tags[-1]:
             raise Exception("invalid html")
             raise Exception("invalid html")
+
         self.tags.pop()
         self.tags.pop()
 
 
     def is_valid_tag(self):
     def is_valid_tag(self):