santuario-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Colm O hEigeartaigh <cohei...@apache.org>
Subject Re: small bug
Date Fri, 13 May 2011 08:53:01 GMT
This has already been fixed as part of SANTUARIO-262:

https://issues.apache.org/jira/browse/SANTUARIO-262

Colm.

On Fri, May 13, 2011 at 3:50 AM, Giedrius Noreikis
<giedrius.noreikis@gmail.com> wrote:
> And why did you change your mind so quickly? :)
>
> The statement that getBytes() uses platform's default charset is absolutely
> correct. It's by design (and a bad one).
> From this follows that
>
> "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".getBytes()
>
> will produce different results on different platforms - as designed and
> documented.
>
> Since the string above contains characters from the first half of ASCII
> table only, the result will be the same for most encodings - but not for
> all, of course ;)
> Trivial examples are encodings using more that one byte to represent a
> character (e.g. UTF-16, UTF-32). Another nice example is a good old EBCDIC,
> which is rather different from ASCII :) And yes, it's still used - Java
> running on z/OS will use EBCDIC as the platform's default :)
>
> Giedrius
>
>
> On 2011.05.13 02:17, George Stanchev wrote:
>
> And I am a duh…just reread my email. Please disregard it. Totally non-issue.
>
>
>
> From: George Stanchev [mailto:Gstanchev@serena.com]
> Sent: Thursday, May 12, 2011 3:59 PM
> To: dev@santuario.apache.org
> Subject: small bug
>
>
>
> Hi,
>
>
>
> This a small bug I ran into while browsing the source for something else.
> Not sure if it deserves a JIRA even (let me know and I will submit one if
> needed)
>
>
>
> In \src\main\java\org\apache\xml\security\utils\XMLUtils.java there is the
> following snippet:
>
>
>
> public static void outputDOM(Node contextNode, OutputStream os,
>
>                                 boolean addPreamble) {
>
>
>
>       try {
>
>          if (addPreamble) {
>
>             os.write("<?xml version=\"1.0\"
> encoding=\"UTF-8\"?>\n".getBytes());
>
>          }
>
>
>
> getBytes() is used which returns the platform encoding but the output XML is
> specified as UTF-8. Therefore .getBytes(“UTF-8”) should be used.
>
>
>
> Since this has been in the code forever and encryption or signature nodes
> are (probably) all standard 7 bit ASCII, this is not a big deal but it’s
> nice to put the correct code in it when someone from the devs is doing a
> commit.
>
>
>
> George

Mime
View raw message