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.
832{
833 if (!env || !name)
834 return 0;
835
836 bool matched = false;
837
838 switch (name[0] | 0x20)
839 {
840 case 'a':
841 if ((name_len == 13) &&
eqi12(name + 1,
"pparently-to"))
842 {
844 matched = true;
845 }
846 else if ((name_len == 15) &&
eqi14(name + 1,
"pparently-from"))
847 {
849 matched = true;
850 }
851#ifdef USE_AUTOCRYPT
852 else if ((name_len == 9) &&
eqi8(name + 1,
"utocrypt"))
853 {
855 if (c_autocrypt)
856 {
858 matched = true;
859 }
860 }
861 else if ((name_len == 16) &&
eqi15(name + 1,
"utocrypt-gossip"))
862 {
864 if (c_autocrypt)
865 {
867 matched = true;
868 }
869 }
870#endif
871 break;
872
873 case 'b':
874 if ((name_len == 3) &&
eqi2(name + 1,
"cc"))
875 {
877 matched = true;
878 }
879 break;
880
881 case 'c':
882 if ((name_len == 2) &&
eqi1(name + 1,
"c"))
883 {
885 matched = true;
886 }
887 else
888 {
889 if ((name_len >= 12) &&
eqi8(name,
"content-"))
890 {
891 if ((name_len == 12) &&
eqi4(name + 8,
"type"))
892 {
893 if (e)
895 matched = true;
896 }
897 else if ((name_len == 16) &&
eqi8(name + 8,
"language"))
898 {
899 if (e)
901 matched = true;
902 }
903 else if ((name_len == 25) &&
eqi17(name + 8,
"transfer-encoding"))
904 {
905 if (e)
907 matched = true;
908 }
909 else if ((name_len == 14) &&
eqi8(name + 6,
"t-length"))
910 {
911 if (e)
912 {
913 unsigned long len = 0;
915 }
916 matched = true;
917 }
918 else if ((name_len == 19) &&
eqi11(name + 8,
"description"))
919 {
920 if (e)
921 {
924 }
925 matched = true;
926 }
927 else if ((name_len == 19) &&
eqi11(name + 8,
"disposition"))
928 {
929 if (e)
931 matched = true;
932 }
933 }
934 }
935 break;
936
937 case 'd':
938 if ((name_len != 4) || !
eqi4(name,
"date"))
939 break;
940
942 if (e)
943 {
944 struct Tz tz = { 0 };
945
948 {
952 }
953 }
954 matched = true;
955 break;
956
957 case 'e':
958 if ((name_len == 7) &&
eqi6(name + 1,
"xpires") && e)
959 {
962 {
964 }
965 }
966 break;
967
968 case 'f':
969 if ((name_len == 4) &&
eqi4(name,
"from"))
970 {
972 matched = true;
973 }
974 else if ((name_len == 11) &&
eqi10(name + 1,
"ollowup-to"))
975 {
977 {
980 }
981 matched = true;
982 }
983 break;
984
985 case 'i':
986 if ((name_len != 11) || !
eqi10(name + 1,
"n-reply-to"))
987 break;
988
994 matched = true;
995 break;
996
997 case 'l':
998 if ((name_len == 5) &&
eqi4(name + 1,
"ines"))
999 {
1000 if (e)
1001 {
1002 unsigned int ui = 0;
1005 }
1006
1007 matched = true;
1008 }
1009 else if ((name_len == 9) &&
eqi8(name + 1,
"ist-post"))
1010 {
1011
1013 {
1015 if (mailto)
1016 {
1020 if (c_auto_subscribe)
1022 }
1023 }
1024 matched = true;
1025 }
1026 else if ((name_len == 14) &&
eqi13(name + 1,
"ist-subscribe"))
1027 {
1028
1030 if (uri)
1031 {
1034 }
1035 matched = true;
1036 }
1037 else if ((name_len == 16) &&
eqi15(name + 1,
"ist-unsubscribe"))
1038 {
1039
1041 if (uri)
1042 {
1045 }
1046 matched = true;
1047 }
1048 break;
1049
1050 case 'm':
1051 if ((name_len == 12) &&
eqi11(name + 1,
"ime-version"))
1052 {
1053 if (e)
1055 matched = true;
1056 }
1057 else if ((name_len == 10) &&
eqi9(name + 1,
"essage-id"))
1058 {
1059
1062 matched = true;
1063 }
1064 else
1065 {
1066 if ((name_len >= 13) &&
eqi4(name + 1,
"ail-"))
1067 {
1068 if ((name_len == 13) &&
eqi8(name + 5,
"reply-to"))
1069 {
1070
1073 matched = true;
1074 }
1075 else if ((name_len == 16) &&
eqi11(name + 5,
"followup-to"))
1076 {
1078 matched = true;
1079 }
1080 }
1081 }
1082 break;
1083
1084 case 'n':
1085 if ((name_len == 10) &&
eqi9(name + 1,
"ewsgroups"))
1086 {
1090 matched = true;
1091 }
1092 break;
1093
1094 case 'o':
1095
1096 if ((name_len == 12) &&
eqi11(name + 1,
"rganization"))
1097 {
1100 }
1101 break;
1102
1103 case 'r':
1104 if ((name_len == 10) &&
eqi9(name + 1,
"eferences"))
1105 {
1108 matched = true;
1109 }
1110 else if ((name_len == 8) &&
eqi8(name,
"reply-to"))
1111 {
1113 matched = true;
1114 }
1115 else if ((name_len == 11) &&
eqi10(name + 1,
"eturn-path"))
1116 {
1118 matched = true;
1119 }
1120 else if ((name_len == 8) &&
eqi8(name,
"received"))
1121 {
1123 {
1124 const char *d = strrchr(body, ';');
1125 if (d)
1126 {
1128
1130 }
1131 }
1132 }
1133 break;
1134
1135 case 's':
1136 if ((name_len == 7) &&
eqi6(name + 1,
"ubject"))
1137 {
1140 matched = true;
1141 }
1142 else if ((name_len == 6) &&
eqi5(name + 1,
"ender"))
1143 {
1145 matched = true;
1146 }
1147 else if ((name_len == 6) &&
eqi5(name + 1,
"tatus"))
1148 {
1149 if (e)
1150 {
1151 while (*body)
1152 {
1153 switch (*body)
1154 {
1155 case 'O':
1156 {
1158 break;
1159 }
1160 case 'R':
1162 break;
1163 case 'r':
1165 break;
1166 default:
1167 break;
1168 }
1169 body++;
1170 }
1171 }
1172 matched = true;
1173 }
1174 else if (e && (name_len == 10) &&
eqi1(name + 1,
"u") &&
1175 (
eqi8(name + 2,
"persedes") ||
eqi8(name + 2,
"percedes")))
1176 {
1179 }
1180 break;
1181
1182 case 't':
1183 if ((name_len == 2) &&
eqi1(name + 1,
"o"))
1184 {
1186 matched = true;
1187 }
1188 break;
1189
1190 case 'x':
1191 if ((name_len == 8) &&
eqi8(name,
"x-status"))
1192 {
1193 if (e)
1194 {
1195 while (*body)
1196 {
1197 switch (*body)
1198 {
1199 case 'A':
1201 break;
1202 case 'D':
1204 break;
1205 case 'F':
1207 break;
1208 default:
1209 break;
1210 }
1211 body++;
1212 }
1213 }
1214 matched = true;
1215 }
1216 else if ((name_len == 7) &&
eqi6(name + 1,
"-label"))
1217 {
1220 matched = true;
1221 }
1222 else if ((name_len == 12) &&
eqi11(name + 1,
"-comment-to"))
1223 {
1226 matched = true;
1227 }
1228 else if ((name_len == 4) &&
eqi4(name,
"xref"))
1229 {
1232 matched = true;
1233 }
1234 else if ((name_len == 13) &&
eqi12(name + 1,
"-original-to"))
1235 {
1237 matched = true;
1238 }
1239 break;
1240
1241 default:
1242 break;
1243 }
1244
1245
1246 if (!matched && user_hdrs)
1247 {
1249 char *dup = NULL;
1251
1253 {
1255 if (do_2047)
1256 {
1258 }
1259 }
1260 else
1261 {
1263 }
1264 }
1265
1266 return matched;
1267}
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
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.
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.
char * mutt_extract_message_id(const char *s, size_t *len)
Find a Message-ID.
#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.
bool mutt_strn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings (to a maximum), safely.
LOFF_T length
length (in bytes) of attachment
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?
struct Body * body
List of MIME parts.
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.
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.