Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 2 commits into from
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