Re: CDATA, Script, and Style

On Wed, Mar 18, 2009 at 2:26 PM, Doug Schepers <schepers@w3.org> wrote:

[snipped Doug dissing Robins SVG skills and calling his ]

>> can we at least agree that the existing set of SVG documents that
>> do use <style>, that use <style> content in the limited ways that would
>> actually break (as detailed by Jonas and others), and that might either
>> be served as text/html and or copy-pasted into an HTML document with
>> informed modifications to their prologs but not to their <style>
>> elements is, even without numbers, likely to be pretty small?
>
> Since XHTML also mandates using CDATA sections for <style>, and there's
> quite a lot of pseudo-XHTML content out there, having a common syntax for
> all these languages, for both <script> and <style> (and any other such
> container element that might come along), would seem the most consistent and
> easy to deal with for authors.
>
> Pardon my ignorance, but could someone point me to some persistent
> exploration of the CDATA-in-style issue?  If it's not on the HTML WG wiki,
> could someone put it there so we don't have to go over years-long email
> threads to receive the wisdom?  What exactly is controversial about
>  <style><![CDATA[
>   ...
>  ]]></style>
> in modern browsers?  (Besides the fact that it's hideous and unwieldy to
> type.  Which it is.)

There is no issue at all with someone copying XML-SVG into
application/xhtml+xml. That will work just fine with no issues as both
are XML syntaxes and so will be parsed the same.

The problem is with copying XML-SVG into text/html. Lets take a
trivial example. Taking a modified example from the SVG1.1 spec:

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

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.

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

This is the exact same issue as we have talked about regarding
<script>. It did seem like the majority thought that the above three
conditions were not common enough to be a cause for concern for
<script>.

/ Jonas

[1] http://lists.w3.org/Archives/Public/public-html/2009Mar/0461.html

Received on Wednesday, 18 March 2009 22:57:37 UTC