8353453: URLDecoder should use HexFormat

Reviewed-by: rriggs, jpai
This commit is contained in:
Patrick Strawderman 2025-04-15 11:26:36 +00:00 committed by Jaikiran Pai
parent 4e24dc003c
commit 03fd43fc91

View File

@ -29,6 +29,7 @@ import java.io.*;
import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException;
import java.util.HexFormat;
import java.util.Objects;
/**
@ -204,11 +205,7 @@ public final class URLDecoder {
while ( ((i+2) < numChars) &&
(c=='%')) {
int v = Integer.parseInt(s, i + 1, i + 3, 16);
if (v < 0)
throw new IllegalArgumentException(
"URLDecoder: Illegal hex characters in escape "
+ "(%) pattern - negative value");
int v = HexFormat.fromHexDigits(s, i + 1, i + 3);
bytes[pos++] = (byte) v;
i+= 3;
if (i < numChars)