After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 127877 - escaped quotes in element content
escaped quotes in element content
Status: VERIFIED FIXED
Product: libxslt
Classification: Platform
Component: general
1.0.10
Other Linux
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2003-11-25 09:10 UTC by Tobi
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Tobi 2003-11-25 09:10:27 UTC
Hi

$ xsltproc --version
Using libxml 20602, libxslt 10100 and libexslt 800
xsltproc was compiled against libxml 20602, libxslt 10100 and libexslt 800
libxslt 10100 was compiled against libxml 20602
libexslt 800 was compiled against libxml 20602

In my XSLT there is

<style type="text/css" media="all">@import "pretty_xhtml.css";</style>

When I transform my source doc with XSLTProc the output contains

<style type="text/css" media="all">@import
&quot;pretty_xhtml.css&quot;;</style>

(no matter if I set UTF-8 or US-ASCII as output encoding)

My browser's CSS engine does not handle the import statement when the
quotes are escaped. (IIRC Saxon gave me unescaped quotes)

<style type="text/css" media="all">@import 'pretty_xhtml.css';</style>

results in

<style type="text/css" media="all">@import 'pretty_xhtml.css';</style>

which works in browsers.

Even if the actual issue is with the browser: XSLTProc's behaviour
doesn't seem consistent (" is escaped while ' is not).

Since I see no need to escape quotes in element content I suggest to
not escape them. (I think quotes only need to be escaped inside
attribute values which are delimited by quotes (not apostrophes))

Tobi
Comment 1 Daniel Veillard 2003-11-25 09:17:37 UTC
Well <style> is *very* specific. I can't even tell from
your report how you do the serialization (HTML, XML,
XML + XHTML1 DOCTYPE ?)
Please conform to the request at 
   http://xmlsoft.org/XSLT/bugs.html
and provide full examples to reproduce the problem.

Daniel
Comment 2 Daniel Veillard 2003-11-25 09:17:54 UTC
Well <style> is *very* specific. I can't even tell from
your report how you do the serialization (HTML, XML,
XML + XHTML1 DOCTYPE ?)
Please conform to the request at 
   http://xmlsoft.org/XSLT/bugs.html
and provide full examples to reproduce the problem.

Daniel
Comment 3 Daniel Veillard 2003-11-25 09:18:43 UTC
Pressed the wrong button, state is needinfo !

Daniel
Comment 4 Tobi 2003-11-25 10:12:49 UTC
I can imagine no scenario where quotes in element content should be
escaped. What would be wrong about changing XSLTProc to never escape
them, no matter what serialization options are set?

I don't see how the style element should be an exception, and I don't
see how I would want to get &quot; in the output for a simple " in the
input or in the XSLT.

But to fulfill your request:

quot.xslt:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 version="1.0" xmlns="http://www.w3.org/1999/xhtml">

  <xsl:output 
    method="xml"
    version="1.0"
    indent="yes"
    encoding="US-ASCII"
    doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
    />

  <xsl:template match="/">
    <html>
      <head>
        <style type="text/css" media="all">@import
"pretty_xhtml.css";</style>        
      </head>
      <body>
        <h1>foo</h1>
      </body>
    </html>
  </xsl:template>

</xsl:transform>


quot.xml:

<?xml version="1.0" encoding="UTF-8"?>
<foo/>

$ xsltproc -o quot.xhtml quot.xslt quot.xml
$ cat quot.xhtml
<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html;
charset=US-ASCII" />
    <style type="text/css" media="all">@import
&quot;pretty_xhtml.css&quot;;</style>
  </head>
  <body>
    <h1>foo</h1>
  </body>
</html>
$
Comment 5 Daniel Veillard 2003-11-25 12:46:46 UTC
<style> and <script> MUST be handled differently in HTML,
look at the spec, they are not defined like other elements,
and for XHTML http://www.w3.org/TR/xhtml1/#C_4 indicates
why the serialization code path is different for this element.
So maybe you don't see why I need those informations, I do
see why I need them, that's why I ask, and not a reason to
be so agressive (again !).

Daniel
Comment 6 Tobi 2003-11-25 14:48:53 UTC
> <style> and <script> MUST be handled differently in HTML,
> look at the spec, they are not defined like other elements,
> and for XHTML http://www.w3.org/TR/xhtml1/#C_4 indicates
> why the serialization code path is different for this element.

The escaped quote made the browser ignore the stylesheet which seems
to go against the "HTML compatibility" described in that Appendix.

What's the reason for escaping the quotes?

> So maybe you don't see why I need those informations, I do
> see why I need them, that's why I ask, and not a reason to
> be so agressive

I wasn't agressive. I asked clear technical questions:
"What would be wrong about changing XSLTProc to never escape
them, no matter what serialization options are set?"
and less directly:
Under which cicumstances would want to get &quot; in the output for a
simple '"' in the input or in the XSLT?

There is no personal criticism, no aggression, no attack.

In case you misunderstood my words: Rest assured that my intention was
to discuss technical details, not to offend you in any way or express
anything to you personally.

> (again !)

I'm not sure why you would want to re-open a resolved issue. In case
you forgot, we found out that the problem was just as much on your
side, see
http://mail.gnome.org/archives/xml/2003-November/msg00137.html
Comment 7 Daniel Veillard 2003-11-25 16:34:51 UTC
> What's the reason for escaping the quotes?

  There aren't any. So I must reproduce the problem. Which
is why I asked for a complete set, that's all ! You seems 
to consider it is there on purpose. I don't think it's the case.
Libxml2 does not escape " by default in element content

paphio:~/XML -> cat tst.xml
<bar> "test" </bar>
paphio:~/XML -> xmllint tst.xml
<?xml version="1.0"?>
<bar> "test" </bar>
paphio:~/XML ->

  I knew that, so I said it was probably related to script
because it is handled differently.


>In my XSLT there is
>
><style type="text/css" media="all">@import "pretty_xhtml.css";</style>

  can lead to 3 different code paths depending on the
xsl:output used. I can't see why all 3 would have the problem,
or the same bug exists in all 3 code paths.

Daniel
Comment 8 Daniel Veillard 2003-11-25 18:32:52 UTC
Okay the bug is fixed in CVS now,

Daniel
Comment 9 Daniel Veillard 2004-03-25 11:37:29 UTC
This should be closed by release of libxslt-1.1.5,
                                                                                
  thanks,
                                                                                
Daniel