Pārlūkot izejas kodu

[fix] handle single closing element in HTMLTextExtractor

Adam Tauber 10 gadus atpakaļ
vecāks
revīzija
699fe60e50
1 mainītis faili ar 4 papildinājumiem un 0 dzēšanām
  1. 4
    0
      searx/utils.py

+ 4
- 0
searx/utils.py Parādīt failu

@@ -82,8 +82,12 @@ class HTMLTextExtractor(HTMLParser):
82 82
         self.tags.append(tag)
83 83
 
84 84
     def handle_endtag(self, tag):
85
+        if not self.tags:
86
+            return
87
+
85 88
         if tag != self.tags[-1]:
86 89
             raise Exception("invalid html")
90
+
87 91
         self.tags.pop()
88 92
 
89 93
     def is_valid_tag(self):