This commit is contained in:
Kovid Goyal 2011-12-26 23:55:05 +05:30
parent c7f90b9fc7
commit b715e71fce

View File

@ -85,8 +85,7 @@ def html5_parse(data, max_nesting_depth=500):
# Check that the asinine HTML 5 algorithm did not result in a tree with # Check that the asinine HTML 5 algorithm did not result in a tree with
# insane nesting depths # insane nesting depths
for x in data.iterdescendants(): for x in data.iterdescendants():
if len(x) == 0: if isinstance(x.tag, basestring) and len(x) is 0: # Leaf node
# Leaf node
depth = node_depth(x) depth = node_depth(x)
if depth > max_nesting_depth: if depth > max_nesting_depth:
raise ValueError('html5lib resulted in a tree with nesting' raise ValueError('html5lib resulted in a tree with nesting'