Esempio n. 1
0
// emitQuotedToken transmits the quoted-string value from <name>=<value>
func emitQuotedToken(l *lexrec.Lexer, t lexrec.ItemType) {
	if !l.Accept("=") {
		l.Errorf("emitQuotedToken: expected '=' after '%s', got %q'", itemName(t), l.Peek())
		return
	}

	l.Skip()

	if !lexrec.Quote(l, t, true) {
		l.Errorf("emitToken: expected a quoted string after '%s=', got %q", itemName(t), l.Peek())
	}
}
Esempio n. 2
0
// ignoreToken skips past <name>=<value>, where the value may be a
// token or a quoted-string.
func ignoreToken(l *lexrec.Lexer) {

	p := string(l.Bytes())
	l.Skip()

	if !l.Accept("=") {
		l.Errorf("ignoreToken: after '%s' expected '=', got %q'", p, l.Peek())
		return
	} else {
		l.Skip()
	}

	if l.Peek() == '"' {
		if lexrec.Quote(l, ItemAuthParam, false) {
			l.Skip()
		}
	} else {
		if l.ExceptRun(nontoken) {
			l.Skip()
		} else {
			l.Errorf("ignoreToken: expected a token character, got %q", l.Peek())
		}
	}
}
Esempio n. 3
0
// advanceChallenge skips over an unrecognized WWW-Authenticate challenge.
func advanceChallenge(l *lexrec.Lexer) {
	if l.AcceptRun(whitespace) {
		l.Skip()
	}

	expectParam := true
	for expectParam {
		if l.ExceptRun(nontoken) {
			r := l.Peek()
			if r == '=' {
				l.Accept("=")
				l.Skip()
				if l.Peek() == '"' {
					if lexrec.Quote(l, ItemAuthParam, false) {
						l.Skip()
					}
				} else {
					if l.ExceptRun(nontoken) {
						l.Skip()
					} else {
						l.Errorf("advanceChallenge: expected a token character, got %q", l.Peek())
					}
				}
			} else if isSpace(r) {
				return
			} else {
				l.Errorf("advanceChallenge: expected either whitespace or '=', got %q", l.Peek())
				return
			}

			expectParam = advanceParam(l)
		} else {
			return
		}
	}
}