]> git.phdru.name Git - bookmarks_db.git/commitdiff
Fix a bug: html_tree may have no childNodes
authorOleg Broytman <phd@phdru.name>
Tue, 1 Dec 2015 16:45:20 +0000 (19:45 +0300)
committerOleg Broytman <phd@phdru.name>
Tue, 1 Dec 2015 16:45:20 +0000 (19:45 +0300)
parse_html/bkmk_ph_html5.py

index 6400d02c20b924b0d77e65709c9136ab1647d41e..6d0d38094bea6bd8935b4ddb29455ca458cd7cbf 100644 (file)
@@ -19,12 +19,13 @@ def parse_html(html_text, charset=None, log=None):
     parser = HTML5Parser()
     html_tree = parser.parse(html_text, encoding=charset, parseMeta=bool(charset))
 
-    for node in html_tree.childNodes:
-        if (node.name == 'html') and (node.type != 3): # Skip DocType element
-            html = node
-            break
-    else:
-        html = None
+    html = None
+    if hasattr(html_tree, 'childNodes'):
+        for node in html_tree.childNodes:
+            # Skip DocType element
+            if (node.name == 'html') and (node.type != 3):
+                html = node
+                break
 
     if not html:
         return None