caktus/django-sanitizer — pull request #1 by caioariede (2012-03-30 14:58:57+00:00)
Title: Splitting an empty string does not make sense

In the lines 65 and 66 below, when no attributes/children are specified, it will always put a list containing an empty string `['']` in these variables. So in the line 73, the condition will in fact never be true.

65 allowed_attrs = allowed_attrs.split(',')
66 allowed_children = allowed_children.split(',')
67 # SPECIAL CASE: tag:attrs[] means "no children allowed"
68 # ommission of the [] at all means "any chidlren allowed"
69 # allowed_children = [] if no children are allowed
70 # allowed_children is None is no children are restricted
71 if tag_name.endswith('[]'):
72 allowed_children = []
73 elif not allowed_children:
74 allowed_children = None
75 valid_tags[tag_name] = (allowed_attrs, allowed_children)

For some reason this was causing some problems when handling nested not-well formed html tags, like `

`.