cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "JBert (Commented) (JIRA)" <>
Subject [jira] [Commented] (COCOON3-83) Encoding bug in XMLGenerator (SAX version) when passing a String to the constructor
Date Mon, 12 Dec 2011 11:34:30 GMT


JBert commented on COCOON3-83:

The problem would appear to be in the StringGenerator inner class, in version 3.0.0-alpha
3 the problem is on line 322:

    XMLUtils.toSax(new ByteArrayInputStream(this.xmlString.getBytes()), XMLGenerator.this.getSAXConsumer());

This encodes the String to bytes using the JRE platform encoding. A SAX parser will later
have trouble parsing this bytestream when the XML declares an encoding different from the
platform encoding.

If I look at line 149, there's this:
             XMLUtils.toSax(new String(this.bytes, this.encoding), XMLGenerator.this.getSAXConsumer());

This issue could thus be fixed by simply passing the XML String into the toSax function, like

             XMLUtils.toSax(this.xmlString, XMLGenerator.this.getSAXConsumer());
> Encoding bug in XMLGenerator (SAX version) when passing a String to the constructor
> -----------------------------------------------------------------------------------
>                 Key: COCOON3-83
>                 URL:
>             Project: Cocoon 3
>          Issue Type: Bug
>          Components: cocoon-sax
>    Affects Versions: 3.0.0-alpha-3
>            Reporter: JBert
> When creating a new org.apache.cocoon.sax.component.XMLGenerator instance with a String
argument, the execute method will fail when the XML uses non-ASCII characters.
> See for more info with regards to the code.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message