Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML-Inputstream should not be converted to String and back to InputStream #86

Open
rscadrde opened this issue Jun 15, 2016 · 0 comments

Comments

@rscadrde
Copy link

The commit
956bedf
made correct inputstream parsing fail:

We are using mule-module-apikit 1.7.3 and a mule server 3.7.3 running with file.encoding=Cp1252.

When posting an xml

<?xml version='1.0' encoding='UTF-8'?>
<ns0:BatteryType xmlns:ns0="http://www.ptc.com/flexplm/cunda/batterytype">
  <ns0:Id>18</ns0:Id>
  <ns0:Text>Hörgerätbatterie</ns0:Text>
</ns0:BatteryType>

message to the api kit router it fails validating the schema with:

[Fatal Error] :4:13: Invalid byte 2 of 4-byte UTF-8 sequence.
because RestXmlSchemaValidator first makes a String out of the inputstream with UTF-8 encoding:

input = IOUtils.toString((InputStream) input, muleEvent.getMessage().getEncoding());
and 7 lines later parses it with

data = loadDocument(IOUtils.toInputStream((String) input));
which uses Charset.defaultCharset() = "Cp1252"

and so the xml parser fails as the "ä" is now Cp1252 encoded but xml-header tells him UTF-8'.

Before the commit

https://github.com/mulesoft/apikit/commit/956bedf243dbfd306cfefa6f4b33712953e32455
the code of RestJsonSchemaValidator.java was correct to directly let the DocumentBuilder parse the inputstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant