Parse an email header.
Process a line from an email header. Each line that is recognised is parsed and the information put in the Envelope or Header.
833{
834 if (!env || !name)
835 return 0;
836
837 bool matched = false;
838
839 switch (name[0] | 0x20)
840 {
841 case 'a':
842 if ((name_len == 13) &&
eqi12(name + 1,
"pparently-to"))
843 {
845 matched = true;
846 }
847 else if ((name_len == 15) &&
eqi14(name + 1,
"pparently-from"))
848 {
850 matched = true;
851 }
852#ifdef USE_AUTOCRYPT
853 else if ((name_len == 9) &&
eqi8(name + 1,
"utocrypt"))
854 {
856 if (c_autocrypt)
857 {
859 matched = true;
860 }
861 }
862 else if ((name_len == 16) &&
eqi15(name + 1,
"utocrypt-gossip"))
863 {
865 if (c_autocrypt)
866 {
868 matched = true;
869 }
870 }
871#endif
872 break;
873
874 case 'b':
875 if ((name_len == 3) &&
eqi2(name + 1,
"cc"))
876 {
878 matched = true;
879 }
880 break;
881
882 case 'c':
883 if ((name_len == 2) &&
eqi1(name + 1,
"c"))
884 {
886 matched = true;
887 }
888 else
889 {
890 if ((name_len >= 12) &&
eqi8(name,
"content-"))
891 {
892 if ((name_len == 12) &&
eqi4(name + 8,
"type"))
893 {
894 if (e)
896 matched = true;
897 }
898 else if ((name_len == 16) &&
eqi8(name + 8,
"language"))
899 {
900 if (e)
902 matched = true;
903 }
904 else if ((name_len == 25) &&
eqi17(name + 8,
"transfer-encoding"))
905 {
906 if (e)
908 matched = true;
909 }
910 else if ((name_len == 14) &&
eqi8(name + 6,
"t-length"))
911 {
912 if (e)
913 {
914 unsigned long len = 0;
916 }
917 matched = true;
918 }
919 else if ((name_len == 19) &&
eqi11(name + 8,
"description"))
920 {
921 if (e)
922 {
925 }
926 matched = true;
927 }
928 else if ((name_len == 19) &&
eqi11(name + 8,
"disposition"))
929 {
930 if (e)
932 matched = true;
933 }
934 }
935 }
936 break;
937
938 case 'd':
939 if ((name_len != 4) || !
eqi4(name,
"date"))
940 break;
941
943 if (e)
944 {
945 struct Tz tz = { 0 };
946
949 {
953 }
954 }
955 matched = true;
956 break;
957
958 case 'e':
959 if ((name_len == 7) &&
eqi6(name + 1,
"xpires") && e)
960 {
963 {
965 }
966 }
967 break;
968
969 case 'f':
970 if ((name_len == 4) &&
eqi4(name,
"from"))
971 {
973 matched = true;
974 }
975 else if ((name_len == 11) &&
eqi10(name + 1,
"ollowup-to"))
976 {
978 {
981 }
982 matched = true;
983 }
984 break;
985
986 case 'i':
987 if ((name_len != 11) || !
eqi10(name + 1,
"n-reply-to"))
988 break;
989
995 matched = true;
996 break;
997
998 case 'l':
999 if ((name_len == 5) &&
eqi4(name + 1,
"ines"))
1000 {
1001 if (e)
1002 {
1003 unsigned int ui = 0;
1006 }
1007
1008 matched = true;
1009 }
1010 else if ((name_len == 9) &&
eqi8(name + 1,
"ist-post"))
1011 {
1012
1014 {
1016 if (mailto)
1017 {
1021 if (c_auto_subscribe)
1023 }
1024 }
1025 matched = true;
1026 }
1027 else if ((name_len == 14) &&
eqi13(name + 1,
"ist-subscribe"))
1028 {
1029
1031 if (uri)
1032 {
1035 }
1036 matched = true;
1037 }
1038 else if ((name_len == 16) &&
eqi15(name + 1,
"ist-unsubscribe"))
1039 {
1040
1042 if (uri)
1043 {
1046 }
1047 matched = true;
1048 }
1049 break;
1050
1051 case 'm':
1052 if ((name_len == 12) &&
eqi11(name + 1,
"ime-version"))
1053 {
1054 if (e)
1056 matched = true;
1057 }
1058 else if ((name_len == 10) &&
eqi9(name + 1,
"essage-id"))
1059 {
1060
1063 matched = true;
1064 }
1065 else
1066 {
1067 if ((name_len >= 13) &&
eqi4(name + 1,
"ail-"))
1068 {
1069 if ((name_len == 13) &&
eqi8(name + 5,
"reply-to"))
1070 {
1071
1074 matched = true;
1075 }
1076 else if ((name_len == 16) &&
eqi11(name + 5,
"followup-to"))
1077 {
1079 matched = true;
1080 }
1081 }
1082 }
1083 break;
1084
1085 case 'n':
1086 if ((name_len == 10) &&
eqi9(name + 1,
"ewsgroups"))
1087 {
1091 matched = true;
1092 }
1093 break;
1094
1095 case 'o':
1096
1097 if ((name_len == 12) &&
eqi11(name + 1,
"rganization"))
1098 {
1101 }
1102 break;
1103
1104 case 'r':
1105 if ((name_len == 10) &&
eqi9(name + 1,
"eferences"))
1106 {
1109 matched = true;
1110 }
1111 else if ((name_len == 8) &&
eqi8(name,
"reply-to"))
1112 {
1114 matched = true;
1115 }
1116 else if ((name_len == 11) &&
eqi10(name + 1,
"eturn-path"))
1117 {
1119 matched = true;
1120 }
1121 else if ((name_len == 8) &&
eqi8(name,
"received"))
1122 {
1124 {
1125 const char *d = strrchr(body, ';');
1126 if (d)
1127 {
1129
1131 }
1132 }
1133 }
1134 break;
1135
1136 case 's':
1137 if ((name_len == 7) &&
eqi6(name + 1,
"ubject"))
1138 {
1141 matched = true;
1142 }
1143 else if ((name_len == 6) &&
eqi5(name + 1,
"ender"))
1144 {
1146 matched = true;
1147 }
1148 else if ((name_len == 6) &&
eqi5(name + 1,
"tatus"))
1149 {
1150 if (e)
1151 {
1152 while (*body)
1153 {
1154 switch (*body)
1155 {
1156 case 'O':
1157 {
1159 break;
1160 }
1161 case 'R':
1163 break;
1164 case 'r':
1166 break;
1167 }
1168 body++;
1169 }
1170 }
1171 matched = true;
1172 }
1173 else if (e && (name_len == 10) &&
eqi1(name + 1,
"u") &&
1174 (
eqi8(name + 2,
"persedes") ||
eqi8(name + 2,
"percedes")))
1175 {
1178 }
1179 break;
1180
1181 case 't':
1182 if ((name_len == 2) &&
eqi1(name + 1,
"o"))
1183 {
1185 matched = true;
1186 }
1187 break;
1188
1189 case 'x':
1190 if ((name_len == 8) &&
eqi8(name,
"x-status"))
1191 {
1192 if (e)
1193 {
1194 while (*body)
1195 {
1196 switch (*body)
1197 {
1198 case 'A':
1200 break;
1201 case 'D':
1203 break;
1204 case 'F':
1206 break;
1207 default:
1208 break;
1209 }
1210 body++;
1211 }
1212 }
1213 matched = true;
1214 }
1215 else if ((name_len == 7) &&
eqi6(name + 1,
"-label"))
1216 {
1219 matched = true;
1220 }
1221 else if ((name_len == 12) &&
eqi11(name + 1,
"-comment-to"))
1222 {
1225 matched = true;
1226 }
1227 else if ((name_len == 4) &&
eqi4(name,
"xref"))
1228 {
1231 matched = true;
1232 }
1233 else if ((name_len == 13) &&
eqi12(name + 1,
"-original-to"))
1234 {
1236 matched = true;
1237 }
1238 break;
1239
1240 default:
1241 break;
1242 }
1243
1244
1245 if (!matched && user_hdrs)
1246 {
1248 char *dup = NULL;
1250
1252 {
1254 if (do_2047)
1255 {
1257 }
1258 }
1259 else
1260 {
1262 }
1263 }
1264
1265 return matched;
1266}
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
int mutt_addrlist_parse(struct AddressList *al, const char *s)
Parse a list of email addresses.
void mutt_auto_subscribe(const char *mailto)
Check if user is subscribed to mailing list.
const char * mutt_str_atoul(const char *str, unsigned long *dst)
Convert ASCII string to an unsigned long.
const char * mutt_str_atoui(const char *str, unsigned int *dst)
Convert ASCII string to an unsigned integer.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
void mutt_parse_content_type(const char *s, struct Body *b)
Parse a content type.
char * mutt_rfc2369_first_mailto(const char *body)
Extract the first mailto: URL from an RFC 2369 list.
static struct AutocryptHeader * parse_autocrypt(struct AutocryptHeader *head, const char *s)
Parse an Autocrypt header line.
static void parse_references(struct ListHead *head, const char *s)
Parse references from an email header.
bool mutt_matches_ignore(const char *s)
Does the string match the ignore list.
static void parse_content_language(const char *s, struct Body *b)
Read the content's language.
static void parse_content_disposition(const char *s, struct Body *b)
Parse a content disposition.
char * mutt_extract_message_id(const char *s, size_t *len)
Find a Message-ID.
void mutt_filter_commandline_header_value(char *header)
Sanitise characters in a header value.
#define CONTENT_TOO_BIG
Maximum reasonable Content-Length value (1 GiB) to prevent overflow.
void mutt_env_set_subject(struct Envelope *env, const char *subj)
Set both subject and real_subj to subj.
static bool eqi17(const char *a, const char b[17])
eqi17 - Compare two 17-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons
static bool eqi8(const char *a, const char b[8])
Compare two 8-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons.
static bool eqi11(const char *a, const char b[11])
eqi11 - Compare two 11-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons
static bool eqi6(const char *a, const char b[6])
eqi6 - Compare two 6-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons
static bool eqi13(const char *a, const char b[13])
eqi13 - Compare two 13-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons
static bool eqi4(const char *a, const char b[4])
Compare two 4-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons.
static bool eqi5(const char *a, const char b[5])
eqi5 - Compare two 5-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons
static bool eqi15(const char *a, const char b[15])
eqi15 - Compare two 15-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons
static bool eqi1(const char *a, const char b[1])
Compare two 1-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons.
static bool eqi2(const char *a, const char b[2])
Compare two 2-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons.
#define MIN(a, b)
Return the minimum of two values.
time_t mutt_date_now(void)
Return the number of seconds since the Unix epoch.
time_t mutt_date_parse_date(const char *s, struct Tz *tz_out)
Parse a date string in RFC822 format.
void mutt_str_remove_trailing_ws(char *s)
Trim trailing whitespace from a string.
int mutt_str_asprintf(char **strp, const char *fmt,...)
bool mutt_strn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings (to a maximum), safely.
char * description
content-description
unsigned int zminutes
Minutes away from UTC.
bool mime
Has a MIME-Version header?
int lines
How many lines in the body of this message?
bool old
Email is seen, but unread.
bool zoccident
True, if west of UTC, False if east.
bool flagged
Marked important?
unsigned int zhours
Hours away from UTC.
time_t date_sent
Time when the message was sent (UTC).
bool replied
Email has been replied to.
bool expired
Already expired?
bool deleted
Email is deleted.
time_t received
Time when the message was placed in the mailbox.
struct ListHead userhdrs
user defined headers
char * supersedes
Supersedes header.
char * list_subscribe
This stores a list URI, preferring mailto.
struct AddressList return_path
Return path for the Email.
char *const subject
Email's subject.
struct AddressList to
Email's 'To' list.
char * followup_to
List of 'followup-to' fields.
struct AddressList reply_to
Email's 'reply-to'.
char * message_id
Message ID.
char * x_comment_to
List of 'X-comment-to' fields.
struct AddressList x_original_to
Email's 'X-Original-to'.
struct AutocryptHeader * autocrypt_gossip
Autocrypt Gossip header.
char * newsgroups
List of newsgroups.
struct AddressList mail_followup_to
Email's 'mail-followup-to'.
struct AddressList cc
Email's 'Cc' list.
struct AddressList sender
Email's sender.
struct ListHead references
message references (in reverse order)
struct AutocryptHeader * autocrypt
Autocrypt header.
struct ListHead in_reply_to
in-reply-to header content
struct AddressList bcc
Email's 'Bcc' list.
char * xref
List of cross-references.
char * organization
Organisation header.
char * list_post
This stores a mailto URL, or nothing.
char * list_unsubscribe
This stores a list URI, preferring mailto.
struct AddressList from
Email's 'From' list.
struct ConfigSubset * sub
Inherited config items.
List of recognised Timezones.
unsigned char zminutes
Minutes away from UTC.
bool zoccident
True if west of UTC, False if East.
unsigned char zhours
Hours away from UTC.