1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
11 // isTSpecial returns true if rune is in 'tspecials' as defined by RFC
13 func isTSpecial(r rune) bool {
14 return strings.IndexRune(`()<>@,;:\"/[]?=`, r) != -1
17 // IsTokenChar returns true if rune is in 'token' as defined by RFC
19 func IsTokenChar(r rune) bool {
20 // token := 1*<any (US-ASCII) CHAR except SPACE, CTLs,
22 return r > 0x20 && r < 0x7f && !isTSpecial(r)
25 // IsToken returns true if s is a 'token' as as defined by RFC 1521
27 func IsToken(s string) bool {
31 return strings.IndexFunc(s, isNotTokenChar) < 0
34 // IsQText returns true if rune is in 'qtext' as defined by RFC 822.
35 func IsQText(r int) bool {
36 // CHAR = <any ASCII character> ; ( 0-177, 0.-127.)
37 // qtext = <any CHAR excepting <">, ; => may be folded
38 // "\" & CR, and including
39 // linear-white-space>