Return-Path: Delivered-To: apmail-abdera-dev-archive@www.apache.org Received: (qmail 89733 invoked from network); 24 Dec 2010 09:13:16 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 24 Dec 2010 09:13:16 -0000 Received: (qmail 84117 invoked by uid 500); 24 Dec 2010 09:13:16 -0000 Delivered-To: apmail-abdera-dev-archive@abdera.apache.org Received: (qmail 83864 invoked by uid 500); 24 Dec 2010 09:13:13 -0000 Mailing-List: contact dev-help@abdera.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@abdera.apache.org Delivered-To: mailing list dev@abdera.apache.org Received: (qmail 83854 invoked by uid 99); 24 Dec 2010 09:13:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Dec 2010 09:13:13 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Dec 2010 09:13:10 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id oBO9CmBs027633 for ; Fri, 24 Dec 2010 09:12:49 GMT Message-ID: <24999918.9081293181968852.JavaMail.jira@thor> Date: Fri, 24 Dec 2010 04:12:48 -0500 (EST) From: "Christine Koppelt (JIRA)" To: dev@abdera.apache.org Subject: [jira] Resolved: (ABDERA-251) Charset issue in FOMDiv.getInternalValue() leads to corrupt return value on non-ASCII platforms MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/ABDERA-251?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Christine Koppelt resolved ABDERA-251. -------------------------------------- Resolution: Fixed fixed in trunk. Thanks for the patch. > Charset issue in FOMDiv.getInternalValue() leads to corrupt return value on non-ASCII platforms > ----------------------------------------------------------------------------------------------- > > Key: ABDERA-251 > URL: https://issues.apache.org/jira/browse/ABDERA-251 > Project: Abdera > Issue Type: Bug > Affects Versions: 0.4.0, 1.0 > Environment: z/OS > Reporter: Robin Fernandes > Assignee: Christine Koppelt > > In org.apache.abdera.parser.stax.FOMDiv.getInternalValue(), the content of the div is obtained as a byte array using an XMLStreamWriter. > The content of the byte array is then converted to String using the default platform encoding (using ByteArrayOutputStream.toString()), which may not be compatible with the encoding used by the XMLStreamWriter. > A scenario in which this is problematic is if the XMLStreamWriter uses UTF8 (which is the default behaviour), but FOMDiv.getInternalValue() is invoked on z/OS where the platform encoding is a flavour of EBCDIC. In this situation, the method returns garbage. > Here's a suggested patch which ensures the XMLStreamWriter writes directly to a StringWriter, so no 'bytes to String' conversion is required in FOMDiv, and therefore no transcoding issues arise. The patch also remove seemingly unnecessary calls to XMLStreamWriter.writeStartElement() and XMLStreamWriter.writeEndElement(). > Index: parser/src/main/java/org/apache/abdera/parser/stax/FOMDiv.java > =================================================================== > --- parser/src/main/java/org/apache/abdera/parser/stax/FOMDiv.java (revision 834082) > +++ parser/src/main/java/org/apache/abdera/parser/stax/FOMDiv.java (working copy) > @@ -17,7 +17,7 @@ > */ > package org.apache.abdera.parser.stax; > > -import java.io.ByteArrayOutputStream; > +import java.io.StringWriter; > import java.util.Iterator; > > import javax.xml.namespace.QName; > @@ -143,16 +143,14 @@ > > protected String getInternalValue() { > try { > - ByteArrayOutputStream out = new ByteArrayOutputStream(); > + StringWriter out = new StringWriter(); > XMLStreamWriter writer = > XMLOutputFactory.newInstance().createXMLStreamWriter(out); > - writer.writeStartElement(""); > for (Iterator nodes = this.getChildren(); nodes.hasNext();) { > OMNode node = (OMNode) nodes.next(); > node.serialize(writer); > } > - writer.writeEndElement(); > - return out.toString().substring(2); > + return out.getBuffer().toString(); > } catch (Exception e) {} > return ""; > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.