]> git.phdru.name Git - bookmarks_db.git/blobdiff - Robots/bkmk_robot_base.py
Fix(parse_html): Do not parse empty strings
[bookmarks_db.git] / Robots / bkmk_robot_base.py
index 1d762d94d1713f951d583f120d658f2f9f8d17dd..f32e1b304d45aab959b047d51db4140241b90633 100644 (file)
@@ -144,13 +144,12 @@ class robot_base(Robot):
                     except (ValueError, IndexError):
                         charset = None
                         self.log("   no charset in Content-Type header")
+                    is_html = False
                     for ctype in ("text/html", "application/xhtml+xml"):
                         if content_type.startswith(ctype):
-                            html = True
+                            is_html = True
                             break
-                    else:
-                        html = False
-                    if html:
+                    if content and is_html:
                         parser = parse_html(content, charset, self.log)
                         if parser:
                             bookmark.real_title = parser.title
@@ -247,6 +246,10 @@ class robot_base(Robot):
                                                   % (url, timeout)
                                                   )
 
+                    if not content:
+                        self.log("   empty response, no content")
+                    if not is_html:
+                        self.log("   not html")
                 except KeyError as key:
                     self.log("   no header: %s" % key)