If ReadMIMEHeader returns an error because the MIME header is invalid, the string in that error contains the original MIME header, which can end up being invalid Unicode. The error string should be escaped, perhaps by formatting the MIME header as a list of byte values if utf8.ValidString returns false on it.
If ReadMIMEHeader returns an error because the MIME header is invalid, the string in that error contains the original MIME header, which can end up being invalid Unicode. The error string should be escaped, perhaps by formatting the MIME header as a list of byte values if utf8.ValidString returns false on it.