Skip to content
Permalink
Browse files

Refine handling of illegal characters in userinfo (#70)

  • Loading branch information...
sideshowbarker authored and smola committed Dec 17, 2018
1 parent 242ae66 commit 35b54cc8bf93e5ed986d7e567118930f710ee53d
@@ -532,6 +532,7 @@ else if (c == '#') {

for (int i = 0; i < buffer.codePointCount(0, buffer.length()); i++) {
final int otherChar = buffer.codePointAt(i);
final char startChar = buffer.charAt(i);
if (
otherChar == 0x0009 ||
otherChar == 0x000A ||
@@ -540,8 +541,8 @@ else if (c == '#') {
handleIllegalWhitespaceError();
continue;
}
if (!isURLCodePoint(otherChar) && otherChar != '%') {
handleIllegalCharacterError("Illegal character in user or password", buffer.codePointAt(i));
if (!isURLCodePoint(startChar) && startChar != '%') {
handleIllegalCharacterError("Illegal character in user or password", otherChar);
}
if (otherChar == '%') {
if (i + 2 >= buffer.length() || !isASCIIHexDigit(buffer.charAt(i+1)) || !isASCIIHexDigit(buffer.charAt(i+2))) {
@@ -42,6 +42,7 @@
{ "http://www.example.com/%", ParseIssue.INVALID_PERCENT_ENCODING, false },
{ "http://www.example.com\\path", ParseIssue.BACKSLASH_AS_DELIMITER, false },
{ "http://us`er:pass@www.example.com/path", ParseIssue.ILLEGAL_CHARACTER, false },
{ "http://:\uD83D\uDCA9@example.com/bar", ParseIssue.ILLEGAL_CHARACTER, false },
{ "http://www.exam\tple.com/path", ParseIssue.ILLEGAL_WHITESPACE, false },
{ "http://user:pass@/path", ParseIssue.INVALID_HOST, true }
});

0 comments on commit 35b54cc

Please sign in to comment.
You can’t perform that action at this time.