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.
801{
802 if (!env || !name)
803 return 0;
804
805 bool matched = false;
806
807 switch (name[0] | 0x20)
808 {
809 case 'a':
810 if ((name_len == 13) &&
eqi12(name + 1,
"pparently-to"))
811 {
813 matched = true;
814 }
815 else if ((name_len == 15) &&
eqi14(name + 1,
"pparently-from"))
816 {
818 matched = true;
819 }
820#ifdef USE_AUTOCRYPT
821 else if ((name_len == 9) &&
eqi8(name + 1,
"utocrypt"))
822 {
824 if (c_autocrypt)
825 {
827 matched = true;
828 }
829 }
830 else if ((name_len == 16) &&
eqi15(name + 1,
"utocrypt-gossip"))
831 {
833 if (c_autocrypt)
834 {
836 matched = true;
837 }
838 }
839#endif
840 break;
841
842 case 'b':
843 if ((name_len == 3) &&
eqi2(name + 1,
"cc"))
844 {
846 matched = true;
847 }
848 break;
849
850 case 'c':
851 if ((name_len == 2) &&
eqi1(name + 1,
"c"))
852 {
854 matched = true;
855 }
856 else
857 {
858 if ((name_len >= 12) &&
eqi8(name,
"content-"))
859 {
860 if ((name_len == 12) &&
eqi4(name + 8,
"type"))
861 {
862 if (e)
864 matched = true;
865 }
866 else if ((name_len == 16) &&
eqi8(name + 8,
"language"))
867 {
868 if (e)
870 matched = true;
871 }
872 else if ((name_len == 25) &&
eqi17(name + 8,
"transfer-encoding"))
873 {
874 if (e)
876 matched = true;
877 }
878 else if ((name_len == 14) &&
eqi8(name + 6,
"t-length"))
879 {
880 if (e)
881 {
882 unsigned long len = 0;
884 }
885 matched = true;
886 }
887 else if ((name_len == 19) &&
eqi11(name + 8,
"description"))
888 {
889 if (e)
890 {
893 }
894 matched = true;
895 }
896 else if ((name_len == 19) &&
eqi11(name + 8,
"disposition"))
897 {
898 if (e)
900 matched = true;
901 }
902 }
903 }
904 break;
905
906 case 'd':
907 if ((name_len != 4) || !
eqi4(name,
"date"))
908 break;
909
911 if (e)
912 {
913 struct Tz tz = { 0 };
914
917 {
921 }
922 }
923 matched = true;
924 break;
925
926 case 'e':
927 if ((name_len == 7) &&
eqi6(name + 1,
"xpires") && e)
928 {
931 {
933 }
934 }
935 break;
936
937 case 'f':
938 if ((name_len == 4) &&
eqi4(name,
"from"))
939 {
941 matched = true;
942 }
943 else if ((name_len == 11) &&
eqi10(name + 1,
"ollowup-to"))
944 {
946 {
949 }
950 matched = true;
951 }
952 break;
953
954 case 'i':
955 if ((name_len != 11) || !
eqi10(name + 1,
"n-reply-to"))
956 break;
957
963 matched = true;
964 break;
965
966 case 'l':
967 if ((name_len == 5) &&
eqi4(name + 1,
"ines"))
968 {
969 if (e)
970 {
971 unsigned int ui = 0;
974 }
975
976 matched = true;
977 }
978 else if ((name_len == 9) &&
eqi8(name + 1,
"ist-post"))
979 {
980
982 {
984 if (mailto)
985 {
989 if (c_auto_subscribe)
991 }
992 }
993 matched = true;
994 }
995 else if ((name_len == 14) &&
eqi13(name + 1,
"ist-subscribe"))
996 {
997
999 if (uri)
1000 {
1003 }
1004 matched = true;
1005 }
1006 else if ((name_len == 16) &&
eqi15(name + 1,
"ist-unsubscribe"))
1007 {
1008
1010 if (uri)
1011 {
1014 }
1015 matched = true;
1016 }
1017 break;
1018
1019 case 'm':
1020 if ((name_len == 12) &&
eqi11(name + 1,
"ime-version"))
1021 {
1022 if (e)
1024 matched = true;
1025 }
1026 else if ((name_len == 10) &&
eqi9(name + 1,
"essage-id"))
1027 {
1028
1031 matched = true;
1032 }
1033 else
1034 {
1035 if ((name_len >= 13) &&
eqi4(name + 1,
"ail-"))
1036 {
1037 if ((name_len == 13) &&
eqi8(name + 5,
"reply-to"))
1038 {
1039
1042 matched = true;
1043 }
1044 else if ((name_len == 16) &&
eqi11(name + 5,
"followup-to"))
1045 {
1047 matched = true;
1048 }
1049 }
1050 }
1051 break;
1052
1053 case 'n':
1054 if ((name_len == 10) &&
eqi9(name + 1,
"ewsgroups"))
1055 {
1059 matched = true;
1060 }
1061 break;
1062
1063 case 'o':
1064
1065 if ((name_len == 12) &&
eqi11(name + 1,
"rganization"))
1066 {
1069 }
1070 break;
1071
1072 case 'r':
1073 if ((name_len == 10) &&
eqi9(name + 1,
"eferences"))
1074 {
1077 matched = true;
1078 }
1079 else if ((name_len == 8) &&
eqi8(name,
"reply-to"))
1080 {
1082 matched = true;
1083 }
1084 else if ((name_len == 11) &&
eqi10(name + 1,
"eturn-path"))
1085 {
1087 matched = true;
1088 }
1089 else if ((name_len == 8) &&
eqi8(name,
"received"))
1090 {
1092 {
1093 const char *d = strrchr(body, ';');
1094 if (d)
1095 {
1097
1099 }
1100 }
1101 }
1102 break;
1103
1104 case 's':
1105 if ((name_len == 7) &&
eqi6(name + 1,
"ubject"))
1106 {
1109 matched = true;
1110 }
1111 else if ((name_len == 6) &&
eqi5(name + 1,
"ender"))
1112 {
1114 matched = true;
1115 }
1116 else if ((name_len == 6) &&
eqi5(name + 1,
"tatus"))
1117 {
1118 if (e)
1119 {
1120 while (*body)
1121 {
1122 switch (*body)
1123 {
1124 case 'O':
1125 {
1127 break;
1128 }
1129 case 'R':
1131 break;
1132 case 'r':
1134 break;
1135 }
1136 body++;
1137 }
1138 }
1139 matched = true;
1140 }
1141 else if (e && (name_len == 10) &&
eqi1(name + 1,
"u") &&
1142 (
eqi8(name + 2,
"persedes") ||
eqi8(name + 2,
"percedes")))
1143 {
1146 }
1147 break;
1148
1149 case 't':
1150 if ((name_len == 2) &&
eqi1(name + 1,
"o"))
1151 {
1153 matched = true;
1154 }
1155 break;
1156
1157 case 'x':
1158 if ((name_len == 8) &&
eqi8(name,
"x-status"))
1159 {
1160 if (e)
1161 {
1162 while (*body)
1163 {
1164 switch (*body)
1165 {
1166 case 'A':
1168 break;
1169 case 'D':
1171 break;
1172 case 'F':
1174 break;
1175 default:
1176 break;
1177 }
1178 body++;
1179 }
1180 }
1181 matched = true;
1182 }
1183 else if ((name_len == 7) &&
eqi6(name + 1,
"-label"))
1184 {
1187 matched = true;
1188 }
1189 else if ((name_len == 12) &&
eqi11(name + 1,
"-comment-to"))
1190 {
1193 matched = true;
1194 }
1195 else if ((name_len == 4) &&
eqi4(name,
"xref"))
1196 {
1199 matched = true;
1200 }
1201 else if ((name_len == 13) &&
eqi12(name + 1,
"-original-to"))
1202 {
1204 matched = true;
1205 }
1206 break;
1207
1208 default:
1209 break;
1210 }
1211
1212
1213 if (!matched && user_hdrs)
1214 {
1216 char *dup = NULL;
1218
1220 {
1222 if (do_2047)
1223 {
1225 }
1226 }
1227 else
1228 {
1230 }
1231 }
1232
1233 return matched;
1234}
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.