private static bool TrySkipFirstBlob(string input, ref int current, ref int parameterEndIndex)
{
// Find the delimiter: Note that <blob> in "<scheme> <blob>" may be a token, quoted string, name/value
// pair or a Base64 encoded string. So make sure that we don't consider ',' characters within a quoted
// string as delimiter.
while ((current < input.Length) && (input[current] != ','))
{
if (input[current] == '"')
{
int quotedStringLength = 0;
if (HttpRuleParser.GetQuotedStringLength(input, current, out quotedStringLength) !=
HttpParseResult.Parsed)
{
// We have a quote but an invalid quoted-string.
return false;
}
current = current + quotedStringLength;
parameterEndIndex = current - 1; // -1 because 'current' points to the char after the final '"'
}
else
{
int whitespaceLength = HttpRuleParser.GetWhitespaceLength(input, current);
// We don't want trailing whitespace to be considered part of the parameter blob. Increment
// 'parameterEndIndex' only if we don't have a whitespace. E.g. "Basic AbC= , NTLM" should return
// "AbC=" as parameter ignoring the spaces before ','.
if (whitespaceLength == 0)
{
parameterEndIndex = current;
current++;
}
else
{
current = current + whitespaceLength;
}
}
}
return true;
}