Skip to content
This repository was archived by the owner on Jul 15, 2025. It is now read-only.

8349705: java.net.URI.scanIPv4Address throws unnecessary URISyntaxException #203

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/java.base/share/classes/java/net/URI.java
Original file line number Diff line number Diff line change
Expand Up @@ -3466,7 +3466,7 @@ private int scanIPv4Address(int start, int n, boolean strict)
if (q < m) break;
return q;
}
fail("Malformed IPv4 address", q);
if (strict) fail("Malformed IPv4 address", q);
return -1;
}

Expand Down Expand Up @@ -3495,12 +3495,16 @@ private int parseIPv4Address(int start, int n) {
return -1;
}

if (p == -1) {
return p;
}

if (p > start && p < n) {
// IPv4 address is followed by something - check that
// it's a ":" as this is the only valid character to
// follow an address.
if (input.charAt(p) != ':') {
p = -1;
return -1;
}
}

Expand Down