Uploaded image for project: 'XalanJ2'
  1. XalanJ2
  2. XALANJ-2614

Serializer 2.7.2 / Xalan 2.7.2 - Bug using Mime-Encoding 'ISO-8859-1'

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 2.7.2
    • Serialization
    • Security Level: No security risk; visible to anyone (Ordinary problems in Xalan projects. Anybody can view the issue.)
    • None
    • Windows 10, Linux
      Java 9, Java 10

    Description

      We found a problem using Xalan / Serializer with Java 9 and 10 when transforming an XML document with a styleheet containing an output-encoding.

      Simple input
      <?xml version="1.0" encoding="UTF-8"?>
      <Message>
        <Value>This is a test input.</Value>
      </Message>
      
      Simple stylesheet containing an output-encoding
      <?xml version="1.0" encoding="UTF-8"?>
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
          <xsl:output method="text" indent="no" encoding="ISO-8859-1"/>
      
          <xsl:template match="/">
              <xsl:text>Tramsformed text: </xsl:text>
              <xsl:value-of select="//Message/Value"/>
          </xsl:template>
      </xsl:stylesheet>
      
      Simple transformation code
          @Test
          public void test2() throws Exception {
              final InputStream is1 = Java9Test.class.getClassLoader().getResourceAsStream("test/Input.xml");
              assertNotNull(is1);
              final Document input = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is1);
              assertNotNull(input);
      
              final InputStream is2 = Java9Test.class.getClassLoader().getResourceAsStream("test/Transform.xsl");
              assertNotNull(is2);
      
              final OutputStream os = new FileOutputStream("Output-" + System.getProperty("java.version") + ".txt", false);
      
              StreamSource xsl = new StreamSource(is2);
              Transformer t = TransformerFactory.newInstance().newTransformer(xsl);
              DOMSource src = new DOMSource(input);
      
              t.transform(src, new StreamResult(os));
          }
      

      Using Java 7 or Java 8 the result is correct: Tramsformed text: This is a test input.. Using Java 9 or Java 10 the result is not correct:

      &#84;&#114;&#97;&#109;&#115;&#102;&#111;&#114;&#109;&#101;&#100;&#32;&#116;&#101;&#120;&#116;&#58;&#32;&#84;&#104;&#105;&#115;&#32;&#105;&#115;&#32;&#97;&#32;&#116;&#101;&#115;&#116;&#32;&#105;&#110;&#112;&#117;&#116;&#46;
      

      indicating an invalid or unknown encoding.

      In Java 7 or Java 8 org.apache.xml.serializer.Encodings.getEncodingInfo("ISO-8859-1") returns "ISO8859_1" which is a valid Java encoding name. In Java 9 oder Java 10 the method returns "8859-1" which is not a valid name.

      The problem is caused by a change to the method keys() in the java.util.Properties class. This method returns die entries of the Encodings.properties in a different order since Java 9.

      Attachments

        1. test.zip
          2 kB
          Jens Annighöfer

        Activity

          People

            jkesselm Joseph Kessselman
            5wA6as Jens Annighöfer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: