From 5ff4c17907d5b19510a62e08fd8d3b11e62b431d Mon Sep 17 00:00:00 2001 From: Ondřej Surý Date: Tue, 13 Sep 2011 13:13:40 +0200 Subject: Imported Upstream version 60 --- src/pkg/mime/grammar.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/pkg/mime/grammar.go (limited to 'src/pkg/mime/grammar.go') diff --git a/src/pkg/mime/grammar.go b/src/pkg/mime/grammar.go new file mode 100644 index 000000000..6e319ff8b --- /dev/null +++ b/src/pkg/mime/grammar.go @@ -0,0 +1,36 @@ +// Copyright 2010 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package mime + +import ( + "strings" +) + +// isTSpecial returns true if rune is in 'tspecials' as defined by RFC +// 1521 and RFC 2045. +func isTSpecial(rune int) bool { + return strings.IndexRune(`()<>@,;:\"/[]?=`, rune) != -1 +} + +// IsTokenChar returns true if rune is in 'token' as defined by RFC +// 1521 and RFC 2045. +func IsTokenChar(rune int) bool { + // token := 1* + return rune > 0x20 && rune < 0x7f && !isTSpecial(rune) +} + +// IsQText returns true if rune is in 'qtext' as defined by RFC 822. +func IsQText(rune int) bool { + // CHAR = ; ( 0-177, 0.-127.) + // qtext = , ; => may be folded + // "\" & CR, and including + // linear-white-space> + switch rune { + case '"', '\\', '\r': + return false + } + return rune < 0x80 +} -- cgit v1.2.3