[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-openjfx-dev
Subject:    Integrated: 8311216: DataURI can lose information in some charset environments
From:       Michael =?UTF-8?B?U3RyYXXDnw==?= <mstrauss () openjdk ! org>
Date:       2023-10-30 18:51:49
Message-ID: 2jXm2iokbUEOnIjRY-S79w6QFqZc_7EHDWffh3bR6ro=.3c1654bc-6831-4a08-8513-2af9c2b9b215 () github ! com
[Download RAW message or body]

On Sat, 1 Jul 2023 22:24:09 GMT, Michael Strauß <mstrauss@openjdk.org> wrote:

> DataURI uses the following implementation to decode the percent-encoded payload of \
> a "data" URI: 
> 
> ...
> String data = uri.substring(dataSeparator + 1);
> Charset charset = Charset.defaultCharset();
> ...
> URLDecoder.decode(data.replace("+", "%2B"), charset).getBytes(charset)
> 
> 
> This approach only works if the charset that is passed into `URLDecoder.decode` and \
> `String.getBytes` doesn't lose information when converting between `String` and \
> `byte[]` representations, as might happen in a US-ASCII environment. 
> This PR solves the problem by not using `URLDecoder`, but instead simply decoding \
> percent-encoded escape sequences as specified by RFC 3986, page 11. 
> **Note to reviewers**: the failing test can only be observed when the JVM uses a \
> default charset that can't represent the payload, which can be enforced by \
> specifying the `-Dfile.encoding=US-ASCII` VM option.

This pull request has now been integrated.

Changeset: f0246b84
Author:    Michael Strauß <mstrauss@openjdk.org>
URL:       https://git.openjdk.org/jfx/commit/f0246b843822d2d888bc1c9fd450b9b371671186
                
Stats:     133 lines in 2 files changed: 121 ins; 5 del; 7 mod

8311216: DataURI can lose information in some charset environments

Reviewed-by: angorya, jhendrikx

-------------

PR: https://git.openjdk.org/jfx/pull/1165


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic