RFR: 8311216: DataURI can lose information in some charset environments [v2]

Michael Strauß mstrauss at openjdk.org
Sat Jul 8 23:38:06 UTC 2023


On Fri, 7 Jul 2023 20:45:59 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

>> Michael Strauß has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   added more tests
>
> modules/javafx.graphics/src/test/java/test/com/sun/javafx/util/DataURITest.java line 183:
> 
>> 181:         // We use URLEncoder here to escape the emoji character using percent-encoding.
>> 182:         // When DataURI parses its payload, it automatically converts percent-encoded characters back to octets.
>> 183:         String input = URLEncoder.encode("🙂", StandardCharsets.UTF_8);
> 
> would it make sense to try several different strings that include +, \n, \t, data:, charset:, %, empty string, &, _, %zz?

Most of these cases should already be covered by existing tests (`testMissingDataSeparatorIsInvalid`, `testParametersListWithoutKeyValuePairsIsInvalid`, `testLeadingOrTrailingWhitespaceIsAcceptable`).

> modules/javafx.graphics/src/test/java/test/com/sun/javafx/util/DataURITest.java line 203:
> 
>> 201: 
>> 202:         ex = assertThrows(IllegalArgumentException.class, () -> DataURI.tryParse("data:,%0"));
>> 203:         assertTrue(ex.getMessage().startsWith("Incomplete"));
> 
> "%", "", null ?

I've added tests for these inputs.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1165#discussion_r1257386139
PR Review Comment: https://git.openjdk.org/jfx/pull/1165#discussion_r1257385872


More information about the openjfx-dev mailing list