[Checkins] SVN: zope.tal/trunk/ avoid spurious NestingErrors due to misparsing of end tags within scripts
David Glick
davidglick at onenw.org
Wed Feb 15 02:00:50 UTC 2012
Log message for revision 124396:
avoid spurious NestingErrors due to misparsing of end tags within scripts
Changed:
U zope.tal/trunk/CHANGES.txt
U zope.tal/trunk/src/zope/tal/htmltalparser.py
U zope.tal/trunk/src/zope/tal/tests/test_htmltalparser.py
-=-
Modified: zope.tal/trunk/CHANGES.txt
===================================================================
--- zope.tal/trunk/CHANGES.txt 2012-02-14 19:04:29 UTC (rev 124395)
+++ zope.tal/trunk/CHANGES.txt 2012-02-15 02:00:47 UTC (rev 124396)
@@ -5,6 +5,9 @@
3.6.1 (unreleased)
------------------
+- Avoid handling end tags within <script> tags. This works around
+ http://bugs.python.org/issue670664
+
- Fixed documentation link in README.txt.
3.6.0 (2011-08-20)
Modified: zope.tal/trunk/src/zope/tal/htmltalparser.py
===================================================================
--- zope.tal/trunk/src/zope/tal/htmltalparser.py 2012-02-14 19:04:29 UTC (rev 124395)
+++ zope.tal/trunk/src/zope/tal/htmltalparser.py 2012-02-15 02:00:47 UTC (rev 124396)
@@ -174,6 +174,9 @@
self.pop_xmlns()
def handle_endtag(self, tag):
+ if self.tagstack and self.tagstack[-1] == 'script' and tag != 'script':
+ self.handle_data('</%s>' % tag)
+ return
if tag in EMPTY_HTML_TAGS:
# </img> etc. in the source is an error
raise EmptyTagError(tag, self.getpos())
Modified: zope.tal/trunk/src/zope/tal/tests/test_htmltalparser.py
===================================================================
--- zope.tal/trunk/src/zope/tal/tests/test_htmltalparser.py 2012-02-14 19:04:29 UTC (rev 124395)
+++ zope.tal/trunk/src/zope/tal/tests/test_htmltalparser.py 2012-02-15 02:00:47 UTC (rev 124396)
@@ -446,6 +446,12 @@
('rawtextOffset',
('<script type="text/javascript">code</script>', 44))
])
+
+ def test_script_5(self):
+ self._run_check("""<script type="text/javascript">var foo = '<div></div>';</script>""", [
+ ('rawtextOffset',
+ ("""<script type="text/javascript">var foo = '<div></div>';</script>""", 64))
+ ])
def test_attributes_1(self):
self._run_check("<a href='foo' name='bar' tal:attributes="
More information about the checkins
mailing list