- From: Philip Taylor <philip@zaynar.demon.co.uk>
- Date: Thu, 02 Aug 2007 20:24:49 +0100
- To: public-html@w3.org
Sam Ruby wrote: > The default processing by existing user agents is to > render text nodes even when they are enclosed in unknown markup. In > some cases, this may not be desirable. The XML CDATA[] syntax is > treated as a comment by HTML parsers, so this may be used to “cloak” > such text regions. <![CDATA[...]]> in HTML doesn't appear to be handled usefully by any of IE/FF/Opera/Safari, and not interoperably by most, and not sanely by some. After writing "<![CDATA[": IE7, Safari 3: Closes after the first '>'. Firefox 3: Closes after the first '>' which is after a ']'. Opera 9.2: Counts the nesting depth of square brackets (starting at 2 in this case), incrementing on each '[' and decrementing on each ']' (allowing a negative nesting depth), and when it sees the first '>' at nesting depth 0 then it deletes the prior two characters and adds a CDATA node to the DOM. (It does the same for anything else that starts with "<!" and doesn't start with "<!--", except it doesn't create the CDATA node.) <http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21%5BCDATA%5B%202%20%3E%201%20%5D%5D%3E> <http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C![CDATA[%20x[0]%20%3E%200)%20]%3E> <http://software.hixie.ch/utilities/js/live-dom-viewer/?x%3C%21%5BCDATA%5B%20%5D%20%5D%5D%3E%20%5B%3Ex> It would work alright across the browsers if you never put any '[', ']' or '>' inside the CDATA section, but that seems too limited to be of any value. -- Philip Taylor philip@zaynar.demon.co.uk
Received on Thursday, 2 August 2007 19:24:51 UTC