parseMessageIDList splits a References / In-Reply-To header value into individual message-ids. The header format is one or more tokens separated by whitespace (RFC 5322 § 3.6.4); the official grammar is permissive enough that we tokenize on whitespace and then trim — any fragment that
(header string)
| 127 | // is permissive enough that we tokenize on whitespace and then trim — any |
| 128 | // fragment that isn't bracketed is dropped. |
| 129 | func parseMessageIDList(header string) []string { |
| 130 | if header == "" { |
| 131 | return nil |
| 132 | } |
| 133 | fields := strings.Fields(header) |
| 134 | out := make([]string, 0, len(fields)) |
| 135 | for _, f := range fields { |
| 136 | if strings.HasPrefix(f, "<") && strings.HasSuffix(f, ">") && len(f) > 2 { |
| 137 | out = append(out, f) |
| 138 | } |
| 139 | } |
| 140 | return out |
| 141 | } |
| 142 | |
| 143 | // parseAddressList parses an RFC 5322 address list header and returns |
| 144 | // lowercased bare email addresses. Invalid entries are silently skipped. |
no test coverage detected