Skip to content

Commit 03fd43f

Browse files
kilinkjaikiran
authored andcommitted
8353453: URLDecoder should use HexFormat
Reviewed-by: rriggs, jpai
1 parent 4e24dc0 commit 03fd43f

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/java.base/share/classes/java/net/URLDecoder.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.nio.charset.Charset;
3030
import java.nio.charset.IllegalCharsetNameException;
3131
import java.nio.charset.UnsupportedCharsetException;
32+
import java.util.HexFormat;
3233
import java.util.Objects;
3334

3435
/**
@@ -204,11 +205,7 @@ public static String decode(String s, Charset charset) {
204205

205206
while ( ((i+2) < numChars) &&
206207
(c=='%')) {
207-
int v = Integer.parseInt(s, i + 1, i + 3, 16);
208-
if (v < 0)
209-
throw new IllegalArgumentException(
210-
"URLDecoder: Illegal hex characters in escape "
211-
+ "(%) pattern - negative value");
208+
int v = HexFormat.fromHexDigits(s, i + 1, i + 3);
212209
bytes[pos++] = (byte) v;
213210
i+= 3;
214211
if (i < numChars)

0 commit comments

Comments
 (0)