8297687: new URI(S,S,S,S) throws exception with incorrect index position reported in the error message

Reviewed-by: jpai
This commit is contained in:
Daniel Fuchs 2022-12-06 12:46:01 +00:00
parent 2243646fe3
commit b0e54328c5
2 changed files with 51 additions and 3 deletions

View file

@ -3239,6 +3239,7 @@ public final class URI
{
int p = start;
int q = p;
int qreg = p;
URISyntaxException ex = null;
boolean serverChars;
@ -3250,7 +3251,7 @@ public final class URI
} else {
serverChars = (scan(p, n, L_SERVER, H_SERVER) == n);
}
regChars = (scan(p, n, L_REG_NAME, H_REG_NAME) == n);
regChars = ((qreg = scan(p, n, L_REG_NAME, H_REG_NAME)) == n);
if (regChars && !serverChars) {
// Must be a registry-based authority
@ -3294,7 +3295,7 @@ public final class URI
// a malformed IPv6 address
throw ex;
} else {
fail("Illegal character in authority", q);
fail("Illegal character in authority", serverChars ? q : qreg);
}
}