You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by "JBert (Created) (JIRA)" <ji...@apache.org> on 2011/12/12 12:26:30 UTC

[jira] [Created] (COCOON3-83) Encoding bug in XMLGenerator (SAX version) when passing a String to the constructor

Encoding bug in XMLGenerator (SAX version) when passing a String to the constructor
-----------------------------------------------------------------------------------

                 Key: COCOON3-83
                 URL: https://issues.apache.org/jira/browse/COCOON3-83
             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 http://stackoverflow.com/a/8471886/983949 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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Closed] (COCOON3-83) Encoding bug in XMLGenerator (SAX version) when passing a String to the constructor

Posted by "Francesco Chicchiriccò (Closed JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COCOON3-83?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Francesco Chicchiriccò closed COCOON3-83.
-----------------------------------------

    Resolution: Fixed

Fix suggested in comments was successfully applied.
                
> Encoding bug in XMLGenerator (SAX version) when passing a String to the constructor
> -----------------------------------------------------------------------------------
>
>                 Key: COCOON3-83
>                 URL: https://issues.apache.org/jira/browse/COCOON3-83
>             Project: Cocoon 3
>          Issue Type: Bug
>          Components: cocoon-sax
>    Affects Versions: 3.0.0-alpha-3
>            Reporter: JBert
>            Assignee: Francesco Chicchiriccò
>             Fix For: 3.0.0-beta-1
>
>
> 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 http://stackoverflow.com/a/8471886/983949 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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (COCOON3-83) Encoding bug in XMLGenerator (SAX version) when passing a String to the constructor

Posted by "JBert (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON3-83?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13167455#comment-13167455 ] 

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:

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

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:
{code}
             XMLUtils.toSax(new String(this.bytes, this.encoding), XMLGenerator.this.getSAXConsumer());
{code}

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

{code}
             XMLUtils.toSax(this.xmlString, XMLGenerator.this.getSAXConsumer());
{code}
                
> Encoding bug in XMLGenerator (SAX version) when passing a String to the constructor
> -----------------------------------------------------------------------------------
>
>                 Key: COCOON3-83
>                 URL: https://issues.apache.org/jira/browse/COCOON3-83
>             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 http://stackoverflow.com/a/8471886/983949 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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Assigned] (COCOON3-83) Encoding bug in XMLGenerator (SAX version) when passing a String to the constructor

Posted by "Francesco Chicchiriccò (Assigned JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COCOON3-83?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Francesco Chicchiriccò reassigned COCOON3-83:
---------------------------------------------

    Assignee: Francesco Chicchiriccò
    
> Encoding bug in XMLGenerator (SAX version) when passing a String to the constructor
> -----------------------------------------------------------------------------------
>
>                 Key: COCOON3-83
>                 URL: https://issues.apache.org/jira/browse/COCOON3-83
>             Project: Cocoon 3
>          Issue Type: Bug
>          Components: cocoon-sax
>    Affects Versions: 3.0.0-alpha-3
>            Reporter: JBert
>            Assignee: Francesco Chicchiriccò
>             Fix For: 3.0.0-beta-1
>
>
> 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 http://stackoverflow.com/a/8471886/983949 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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Commented] (COCOON3-83) Encoding bug in XMLGenerator (SAX version) when passing a String to the constructor

Posted by "Hudson (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON3-83?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13167483#comment-13167483 ] 

Hudson commented on COCOON3-83:
-------------------------------

Integrated in Cocoon-trunk #110 (See [https://builds.apache.org/job/Cocoon-trunk/110/])
    COCOON3-83 #resolve

ilgrosso : http://svn.apache.org/viewvc/?view=rev&rev=1213207
Files : 
* /cocoon/cocoon3/trunk/cocoon-sax/src/main/java/org/apache/cocoon/sax/component/XMLGenerator.java

                
> Encoding bug in XMLGenerator (SAX version) when passing a String to the constructor
> -----------------------------------------------------------------------------------
>
>                 Key: COCOON3-83
>                 URL: https://issues.apache.org/jira/browse/COCOON3-83
>             Project: Cocoon 3
>          Issue Type: Bug
>          Components: cocoon-sax
>    Affects Versions: 3.0.0-alpha-3
>            Reporter: JBert
>            Assignee: Francesco Chicchiriccò
>             Fix For: 3.0.0-beta-1
>
>
> 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 http://stackoverflow.com/a/8471886/983949 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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Updated] (COCOON3-83) Encoding bug in XMLGenerator (SAX version) when passing a String to the constructor

Posted by "Francesco Chicchiriccò (Updated JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COCOON3-83?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Francesco Chicchiriccò updated COCOON3-83:
------------------------------------------

    Fix Version/s: 3.0.0-beta-1
    
> Encoding bug in XMLGenerator (SAX version) when passing a String to the constructor
> -----------------------------------------------------------------------------------
>
>                 Key: COCOON3-83
>                 URL: https://issues.apache.org/jira/browse/COCOON3-83
>             Project: Cocoon 3
>          Issue Type: Bug
>          Components: cocoon-sax
>    Affects Versions: 3.0.0-alpha-3
>            Reporter: JBert
>            Assignee: Francesco Chicchiriccò
>             Fix For: 3.0.0-beta-1
>
>
> 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 http://stackoverflow.com/a/8471886/983949 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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

[jira] [Issue Comment Edited] (COCOON3-83) Encoding bug in XMLGenerator (SAX version) when passing a String to the constructor

Posted by "JBert (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON3-83?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13167455#comment-13167455 ] 

JBert edited comment on COCOON3-83 at 12/12/11 11:37 AM:
---------------------------------------------------------

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 so (line 322 again):
             XMLUtils.toSax(this.xmlString, XMLGenerator.this.getSAXConsumer());
                
      was (Author: albertdevs):
    The problem would appear to be in the StringGenerator inner class, in version 3.0.0-alpha 3 the problem is on line 322:

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

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:
{code}
             XMLUtils.toSax(new String(this.bytes, this.encoding), XMLGenerator.this.getSAXConsumer());
{code}

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

{code}
             XMLUtils.toSax(this.xmlString, XMLGenerator.this.getSAXConsumer());
{code}
                  
> Encoding bug in XMLGenerator (SAX version) when passing a String to the constructor
> -----------------------------------------------------------------------------------
>
>                 Key: COCOON3-83
>                 URL: https://issues.apache.org/jira/browse/COCOON3-83
>             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 http://stackoverflow.com/a/8471886/983949 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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira