Re: CDATA, Script, and Style

Hi, Jonas-

Jonas Sicking wrote (on 3/18/09 6:56 PM):
> On Wed, Mar 18, 2009 at 2:26 PM, Doug Schepers<schepers@w3.org>  wrote:
>
> [snipped Doug dissing Robins SVG skills and calling his ]

FWIW, Robin's SVG skills make *you* look like a chump.


> <svg width="10cm" height="5cm" viewBox="0 0 1000 500"
>       xmlns="http://www.w3.org/2000/svg" version="1.1">
>    <defs>
>      <style type="text/css"><![CDATA[
>        svg>  rect {
>          fill: red;
>        }
>      ]]></style>
>    </defs>
>    <rect x="200" y="100" width="600" height="300"/>
> </svg>
>
> This should work great when copied into text/html. As would it if the
> style tag instead looked like:
>
> <style type="text/css">
>    svg>  rect {
>      fill: red;
>    }
> </style>
>
> 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.

And your clear explanation makes *me* look like a chump.  Wow, chumped 
by a chump, how humiliating.

Now, couldn't we define a set of common (in script and style) entities 
that *would* be resolved, just to cover our bases?  Or would that likely 
break content?  I suppose it's likely that somebody out there is using a 
&gt; entity in a string in script or even CSS that they want to stay 
that way...

Plus, it does seem like special casing in a way we might want to avoid.


> 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.

Yes, this is a case I think we could safely lose.


> For markup that uses<![CDATA[]]>  I believe we can ensure that the
> markup will work correctly even in text/html, as detailed in my
> proposal at [1].

Okay, rereading that, it does make sense.  I thought we were talking 
about breaking all instances of CDATA in <style>. Phew!

I'm fine with your proposal, then, favoring solution 1, "Support 
<![CDATA[]]> while tokenizing CDATA."

Regards-
-Doug

p.s. Chump.

Received on Thursday, 19 March 2009 00:21:39 UTC