[Zope] Re: ZPT parser changes from 2.6.x to 2.7.3 ?

Tres Seaver tseaver at zope.com
Tue Nov 16 11:36:00 EST 2004


Fred Drake wrote:
> On Tue, 16 Nov 2004 13:03:07 +0100, Marco Bizzarri <m.bizzarri at icube.it> wrote:
> 
>>     <script><![CDATA[
>>         if (gecko) document.write('</table></td></tr>');
>>     ]]>
> 
> ...
> 
>>Compilation failed
>>TAL.HTMLTALParser.NestingError: Open tags <html>, <body>, <script> do
>>not match close tag </table>, at line 10, column 36
>>
>>therefore, the parse is interpreting the inside of the <script> tag as
>>normal tags instead of simple content of the script.
> 
> 
> Not just any tags; it's catching the "</" in particular.  The parser
> being used doesn't understand <![CDATA[...]]>, so doesn't avoid this
> problem.
> 
> In addition to the options Tonico suggested, there's one more option:
> change the line containing the </table> to:
> 
>          if (gecko) document.write('<' + '/table></td></tr>');
> 
> This avoids the specific behavior you're seeing, and would also work
> without the CDATA marked section.

The HTML spec on dynamic document modification:

  http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.4

points out that you can also escape the forward slash (all of them need 
escaping, not just the first one), e.g.:

   if (gecko) document.write('<\/table><\/td><\/tr>')

Tres.
-- 
===============================================================
Tres Seaver                                tseaver at zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com



More information about the Zope mailing list