Merge "Throw URISyntaxException for incorrect percent-encoding"
This commit is contained in:
commit
5797dbe9a7
|
@ -252,6 +252,11 @@ public URIish(String s) throws URISyntaxException {
|
||||||
throw new URISyntaxException(s, JGitText.get().cannotParseGitURIish);
|
throw new URISyntaxException(s, JGitText.get().cannotParseGitURIish);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int parseHexByte(byte c1, byte c2) {
|
||||||
|
return ((RawParseUtils.parseHexInt4(c1) << 4)
|
||||||
|
| RawParseUtils.parseHexInt4(c2));
|
||||||
|
}
|
||||||
|
|
||||||
private static String unescape(String s) throws URISyntaxException {
|
private static String unescape(String s) throws URISyntaxException {
|
||||||
if (s == null)
|
if (s == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -272,8 +277,14 @@ private static String unescape(String s) throws URISyntaxException {
|
||||||
if (c == '%') {
|
if (c == '%') {
|
||||||
if (i + 2 >= bytes.length)
|
if (i + 2 >= bytes.length)
|
||||||
throw new URISyntaxException(s, JGitText.get().cannotParseGitURIish);
|
throw new URISyntaxException(s, JGitText.get().cannotParseGitURIish);
|
||||||
int val = (RawParseUtils.parseHexInt4(bytes[i + 1]) << 4)
|
byte c1 = bytes[i + 1];
|
||||||
| RawParseUtils.parseHexInt4(bytes[i + 2]);
|
byte c2 = bytes[i + 2];
|
||||||
|
int val;
|
||||||
|
try {
|
||||||
|
val = parseHexByte(c1, c2);
|
||||||
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
|
throw new URISyntaxException(s, JGitText.get().cannotParseGitURIish);
|
||||||
|
}
|
||||||
os[j++] = (byte) val;
|
os[j++] = (byte) val;
|
||||||
i += 2;
|
i += 2;
|
||||||
} else
|
} else
|
||||||
|
|
Loading…
Reference in New Issue