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 55772 - Problem with disabling output escaping
Problem with disabling output escaping
Status: VERIFIED FIXED
Product: libxslt
Classification: Platform
Component: general
unspecified
Other Solaris
: Normal normal
: ---
Assigned To: Daniel Veillard
Daniel Veillard
Depends on:
Blocks:
 
 
Reported: 2001-06-05 19:15 UTC by knighjn
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description knighjn 2001-06-05 19:15:42 UTC
I believe there is a problem with disabling output escaping, using
<xsl:text disable-output-escaping="yes">&lt;</xsl:text> and in placing &lt;
in a <script> element with <xsl:output method="html"/>.

This example should explain.

----------
source.xml
----------
<?xml version="1.0"?>

<exam name="Midterm Exam" id="TK421" timeLimit="00:30:00" hints="true">
  <questions xmlns:xlink="http://www.w3.org/1999/xlink">
    <question type="choice" id="TK421-2" instructionId="1">
      <questionText>A <emphasis>constant</emphasis> is something that does
not change.</questionText>
      <answers>
        <answer id="TK421-2-1" correct="true">True</answer>
        <answer id="TK421-2-2">False</answer>
      </answers>
    </question>
  </questions>
</exam>

--------------
stylesheet.xsl
--------------
<?xml version="1.0" ?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">

  <xsl:output method="html"/>

  <xsl:template match="/">
    <html>
      <head>
        <title><xsl:value-of select="exam/@name"/></title>
        <script>
          <xsl:text disable-output-escaping="yes">&lt;</xsl:text>
          funtion test() {
            var a;
            var b;

            if (a &lt; b) { alert('Hello'); }
          }

          <xsl:text disable-output-escaping="yes">&lt;</xsl:text>
        </script>
      </head>
      <body bgcolor="white">
      </body>
    </html>
  </xsl:template>

</xsl:stylesheet>

---------------------
Output using xsltproc
---------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>Midterm Exam</title>
<script><
          funtion test() {
            var a;
            var b;

            if (a &lt; b) { alert('Hello'); }
          }

          &lt;</script>
</head>
<body bgcolor="white"></body>
</html>

--------------------
Good Output Using XT
--------------------

<html>
<head>
<title>Midterm Exam</title>
<script><
          funtion test() {
            var a;
            var b;

            if (a < b) { alert('Hello'); }
          }

          <</script>
</head>
<body bgcolor="white">
</body>
</html>

Knowing my luck the output I have pasted here will show up wrong because it
envolves entities.  There are three instances of &lt; in the stylesheet,
but only the first is not escaped in the output.
Comment 1 knighjn 2001-06-05 19:51:49 UTC
using libxml2-2.3.10 and libxslt-0.11.0
Comment 2 Daniel Veillard 2001-06-05 21:06:54 UTC
Thanks for the detailed bug description. I fixed the problem
with  a small patch to libxml module HTMLtree.c

http://cvs.gnome.org/bonsai/cvsquery.cgi?module=gnome-xml&branch=HEAD&branchtype=match&dir=gnome-xml&file=&filetype=match&who=veillard&whotype=match&sortby=Date&hours=&date=explicit&mindate=06%2F05%2F01+16%3A57&maxdate=06%2F05%2F01+16%3A57&cvsroot=%2Fcvs%2Fgnome

-----------------------------------------------
orchis:~/XSLT/tests/general -> xsltproc bug-33-.xsl
../docs/bug-33-.xml
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>Midterm Exam</title>
<script><
	 funtion test() {
	   var a;
	   var b;

	   if (a < b) { alert('Hello'); }
	 }

	 <</script>
</head>
<body bgcolor="white"></body>
</html>
orchis:~/XSLT/tests/general -> 
--------------------------------------------------

Daniel
Comment 3 Daniel Veillard 2001-06-17 18:33:29 UTC
The release of libxml-2.3.11 and libxslt-0.12.0 should close the
problem.

Daniel