Commit dec5501d authored by Fred Drake's avatar Fred Drake

Raise TALError when tal:content is used on an HTML tag that must be empty.

parent 36edcfae
......@@ -142,6 +142,10 @@ class HTMLTALParser(HTMLParser):
self.scan_xmlns(attrs)
tag, attrlist, taldict, metaldict, i18ndict \
= self.process_ns(tag, attrs)
if tag in EMPTY_HTML_TAGS and taldict.get("content"):
raise TALError(
"empty HTML tags cannot use tal:content: %s" % `tag`,
self.getpos())
self.tagstack.append(tag)
self.gen.emitStartElement(tag, attrlist, taldict, metaldict, i18ndict,
self.getpos())
......@@ -154,6 +158,10 @@ class HTMLTALParser(HTMLParser):
tag, attrlist, taldict, metaldict, i18ndict \
= self.process_ns(tag, attrs)
if taldict.get("content"):
if tag in EMPTY_HTML_TAGS:
raise TALError(
"empty HTML tags cannot use tal:content: %s" % `tag`,
self.getpos())
self.gen.emitStartElement(tag, attrlist, taldict, metaldict,
i18ndict, self.getpos())
self.gen.emitEndElement(tag, implied=-1)
......
......@@ -478,6 +478,8 @@ class TALGeneratorTestCases(TestCaseBase):
self._should_error("<p tal:foobar='x' />")
self._should_error("<p tal:replace='x' tal:content='x' />")
self._should_error("<p tal:replace='x'>")
for tag in HTMLTALParser.EMPTY_HTML_TAGS:
self._should_error("<%s tal:content='string:foo'>" % tag)
def check_metal_errors(self):
exc = METALError
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment