Skip to content

Commit de3f63c

Browse files
author
duke
committed
Backport a90f323d05f1c90767823b8729b124de0bead265
1 parent 2bf1ce4 commit de3f63c

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
@@ -3466,7 +3466,7 @@ private int scanIPv4Address(int start, int n, boolean strict)
34663466
if (q < m) break;
34673467
return q;
34683468
}
3469-
fail("Malformed IPv4 address", q);
3469+
if (strict) fail("Malformed IPv4 address", q);
34703470
return -1;
34713471
}
34723472

@@ -3495,12 +3495,16 @@ private int parseIPv4Address(int start, int n) {
34953495
return -1;
34963496
}
34973497

3498+
if (p == -1) {
3499+
return p;
3500+
}
3501+
34983502
if (p > start && p < n) {
34993503
// IPv4 address is followed by something - check that
35003504
// it's a ":" as this is the only valid character to
35013505
// follow an address.
35023506
if (input.charAt(p) != ':') {
3503-
p = -1;
3507+
return -1;
35043508
}
35053509
}
35063510

0 commit comments

Comments
 (0)