Skip to content

Commit 23836d5

Browse files
Xiaolong PengVictor Rudometov
authored andcommitted
8349705: java.net.URI.scanIPv4Address throws unnecessary URISyntaxException
Backport-of: a90f323d05f1c90767823b8729b124de0bead265
1 parent a0b7f83 commit 23836d5

File tree

1 file changed

+6
-2
lines changed
  • src/java.base/share/classes/java/net

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3479,7 +3479,7 @@ private int scanIPv4Address(int start, int n, boolean strict)
34793479
if (q < m) break;
34803480
return q;
34813481
}
3482-
fail("Malformed IPv4 address", q);
3482+
if (strict) fail("Malformed IPv4 address", q);
34833483
return -1;
34843484
}
34853485

@@ -3508,12 +3508,16 @@ private int parseIPv4Address(int start, int n) {
35083508
return -1;
35093509
}
35103510

3511+
if (p == -1) {
3512+
return p;
3513+
}
3514+
35113515
if (p > start && p < n) {
35123516
// IPv4 address is followed by something - check that
35133517
// it's a ":" as this is the only valid character to
35143518
// follow an address.
35153519
if (input.charAt(p) != ':') {
3516-
p = -1;
3520+
return -1;
35173521
}
35183522
}
35193523

0 commit comments

Comments
 (0)