RFR: 8353453: URLDecoder should use HexFormat
Chen Liang
liach at openjdk.org
Tue Apr 1 23:02:26 UTC 2025
On Tue, 1 Apr 2025 19:08:13 GMT, Roger Riggs <rriggs at openjdk.org> wrote:
>> Use `HexFormat.fromHexDigits` in URLDecoder, instead of `Integer.parseInt`.
>
> src/java.base/share/classes/java/net/URLDecoder.java line 208:
>
>> 206: while ( ((i+2) < numChars) &&
>> 207: (c=='%')) {
>> 208: int v = HexFormat.fromHexDigits(s, i + 1, i + 3);
>
> Its worth noting that the exceptions thrown by HexFormat.fromHexDigits are different than those thrown by Integer.parseInt, as to the specific type and exception message.
They are both NumberFormatException that is immediately handled by an enclosing catch block. This change should only affect the exception message for inputs fragments like %-F.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24314#discussion_r2023780945
More information about the net-dev
mailing list