Re: CDATA, Script, and Style

Henri Sivonen wrote:
> On Mar 19, 2009, at 00:56, Jonas Sicking wrote:
> 
>> However, if the style was
>>
>> <style type="text/css">
>>  svg &gt; rect {
>>    fill: red;
>>  }
>> </style>
>>
>> then this would work as expected in XML-SVG, but there might possibly
>> be problems when the markup is copied into a text/html document. In
>> HTML, the contents of <style> is parsed as CDATA. That means that no
>> entities are escaped. So the above style tag would contain invalid CSS
>> as the "&gt;" would not be turned into a ">" and so the selector would
>> be invalid and not match anything.
>>
>> So the question is, how common do we think this is? We're looking for
>> how common it is that:
>> 1) An SVG file contains inline <style>, *and*
>> 2) That style does not use <![CDATA[]]> for the contents of the 
>> element, *and*
>> 3) The contents uses entities.
> 
> I don't know how common it is, but this situation arises easily with an 
> XML serializer that never outputs CDATA sections either because it is 
> connected to SAX ContentHandler but not LexicalHandler or just because 
> writing a serializer that doesn't output CDATA sections is some much 
> easier to do correctly.

Depends on the serializer.  Not encoding the ">" is legal inside of text 
regions in XML.  I have two examples of such, inside a style section no 
less, in my html5-evolution page, which is served as 
application/xhtml+xml to browsers such a firefox:

http://intertwingly.net/stories/2009/03/13/html5-evolution.html

I feel that it is important that people be able to copy/paste between 
style sections inside of an HTML document.  *IF* it turns out that it is 
felt important to treat &gt; inside of style sections as a greather than 
sign inside of style sections found in SVG (here, my intuition matches 
Jonas's), then we should explore supporting such in *all* style sections.

My experience here is that asking questions of the form "would allowing 
'X' break the web?" in the context of HTML produces surprisingly quick 
results, so if anybody has the means to answer this question for &gt; 
inside of style sections and is inclined to do so, I would be interested 
in the result.

- Sam Ruby

Received on Thursday, 19 March 2009 12:28:07 UTC