package mailparser import "regexp" // encodedWordRe matches an RFC 2047 encoded-word (=?charset?B|Q?text?=). // Used to detect header values that were stored raw because decoding failed // (e.g. Windows-1252 before the CharsetReader fix in decodeMIMEHeader). var encodedWordRe = regexp.MustCompile(`=\?[^?\s]+\?[BbQq]\?[^?]*\?=`) // HasEncodedWord reports whether s still contains an undecoded RFC 2047 // encoded-word. A correctly decoded subject never contains one. func HasEncodedWord(s string) bool { return encodedWordRe.MatchString(s) } // DecodeMIMEHeader is the exported form of decodeMIMEHeader. It decodes // RFC 2047 encoded-word headers including charsets outside UTF-8/US-ASCII/ // ISO-8859-1 (e.g. Windows-1252). Callers outside the parser need it for // metadata repair runs (subject backfill). func DecodeMIMEHeader(s string) string { return decodeMIMEHeader(s) }