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.
737{
738 if (!env || !name)
739 return 0;
740
741 bool matched = false;
742
743 switch (name[0] | 0x20)
744 {
745 case 'a':
746 if ((name_len == 13) &&
eqi12(name + 1,
"pparently-to"))
747 {
749 matched = true;
750 }
751 else if ((name_len == 15) &&
eqi14(name + 1,
"pparently-from"))
752 {
754 matched = true;
755 }
756#ifdef USE_AUTOCRYPT
757 else if ((name_len == 9) &&
eqi8(name + 1,
"utocrypt"))
758 {
760 if (c_autocrypt)
761 {
763 matched = true;
764 }
765 }
766 else if ((name_len == 16) &&
eqi15(name + 1,
"utocrypt-gossip"))
767 {
769 if (c_autocrypt)
770 {
772 matched = true;
773 }
774 }
775#endif
776 break;
777
778 case 'b':
779 if ((name_len == 3) &&
eqi2(name + 1,
"cc"))
780 {
782 matched = true;
783 }
784 break;
785
786 case 'c':
787 if ((name_len == 2) &&
eqi1(name + 1,
"c"))
788 {
790 matched = true;
791 }
792 else
793 {
794 if ((name_len >= 12) &&
eqi8(name,
"content-"))
795 {
796 if ((name_len == 12) &&
eqi4(name + 8,
"type"))
797 {
798 if (e)
800 matched = true;
801 }
802 else if ((name_len == 16) &&
eqi8(name + 8,
"language"))
803 {
804 if (e)
806 matched = true;
807 }
808 else if ((name_len == 25) &&
eqi17(name + 8,
"transfer-encoding"))
809 {
810 if (e)
812 matched = true;
813 }
814 else if ((name_len == 14) &&
eqi8(name + 6,
"t-length"))
815 {
816 if (e)
817 {
818 unsigned long len = 0;
820 }
821 matched = true;
822 }
823 else if ((name_len == 19) &&
eqi11(name + 8,
"description"))
824 {
825 if (e)
826 {
829 }
830 matched = true;
831 }
832 else if ((name_len == 19) &&
eqi11(name + 8,
"disposition"))
833 {
834 if (e)
836 matched = true;
837 }
838 }
839 }
840 break;
841
842 case 'd':
843 if ((name_len != 4) || !
eqi4(name,
"date"))
844 break;
845
847 if (e)
848 {
849 struct Tz tz = { 0 };
850
853 {
857 }
858 }
859 matched = true;
860 break;
861
862 case 'e':
863 if ((name_len == 7) &&
eqi6(name + 1,
"xpires") && e)
864 {
867 {
869 }
870 }
871 break;
872
873 case 'f':
874 if ((name_len == 4) &&
eqi4(name,
"from"))
875 {
877 matched = true;
878 }
879 else if ((name_len == 11) &&
eqi10(name + 1,
"ollowup-to"))
880 {
882 {
885 }
886 matched = true;
887 }
888 break;
889
890 case 'i':
891 if ((name_len != 11) || !
eqi10(name + 1,
"n-reply-to"))
892 break;
893
899 matched = true;
900 break;
901
902 case 'l':
903 if ((name_len == 5) &&
eqi4(name + 1,
"ines"))
904 {
905 if (e)
906 {
907 unsigned int ui = 0;
910 }
911
912 matched = true;
913 }
914 else if ((name_len == 9) &&
eqi8(name + 1,
"ist-post"))
915 {
916
918 {
920 if (mailto)
921 {
925 if (c_auto_subscribe)
927 }
928 }
929 matched = true;
930 }
931 else if ((name_len == 14) &&
eqi13(name + 1,
"ist-subscribe"))
932 {
933
935 if (mailto)
936 {
939 }
940 matched = true;
941 }
942 else if ((name_len == 16) &&
eqi15(name + 1,
"ist-unsubscribe"))
943 {
944
946 if (mailto)
947 {
950 }
951 matched = true;
952 }
953 break;
954
955 case 'm':
956 if ((name_len == 12) &&
eqi11(name + 1,
"ime-version"))
957 {
958 if (e)
960 matched = true;
961 }
962 else if ((name_len == 10) &&
eqi9(name + 1,
"essage-id"))
963 {
964
967 matched = true;
968 }
969 else
970 {
971 if ((name_len >= 13) &&
eqi4(name + 1,
"ail-"))
972 {
973 if ((name_len == 13) &&
eqi8(name + 5,
"reply-to"))
974 {
975
978 matched = true;
979 }
980 else if ((name_len == 16) &&
eqi11(name + 5,
"followup-to"))
981 {
983 matched = true;
984 }
985 }
986 }
987 break;
988
989 case 'n':
990 if ((name_len == 10) &&
eqi9(name + 1,
"ewsgroups"))
991 {
995 matched = true;
996 }
997 break;
998
999 case 'o':
1000
1001 if ((name_len == 12) &&
eqi11(name + 1,
"rganization"))
1002 {
1005 }
1006 break;
1007
1008 case 'r':
1009 if ((name_len == 10) &&
eqi9(name + 1,
"eferences"))
1010 {
1013 matched = true;
1014 }
1015 else if ((name_len == 8) &&
eqi8(name,
"reply-to"))
1016 {
1018 matched = true;
1019 }
1020 else if ((name_len == 11) &&
eqi10(name + 1,
"eturn-path"))
1021 {
1023 matched = true;
1024 }
1025 else if ((name_len == 8) &&
eqi8(name,
"received"))
1026 {
1028 {
1029 const char *d = strrchr(body, ';');
1030 if (d)
1031 {
1033
1035 }
1036 }
1037 }
1038 break;
1039
1040 case 's':
1041 if ((name_len == 7) &&
eqi6(name + 1,
"ubject"))
1042 {
1045 matched = true;
1046 }
1047 else if ((name_len == 6) &&
eqi5(name + 1,
"ender"))
1048 {
1050 matched = true;
1051 }
1052 else if ((name_len == 6) &&
eqi5(name + 1,
"tatus"))
1053 {
1054 if (e)
1055 {
1056 while (*body)
1057 {
1058 switch (*body)
1059 {
1060 case 'O':
1061 {
1063 break;
1064 }
1065 case 'R':
1067 break;
1068 case 'r':
1070 break;
1071 }
1072 body++;
1073 }
1074 }
1075 matched = true;
1076 }
1077 else if (e && (name_len == 10) &&
eqi1(name + 1,
"u") &&
1078 (
eqi8(name + 2,
"persedes") ||
eqi8(name + 2,
"percedes")))
1079 {
1082 }
1083 break;
1084
1085 case 't':
1086 if ((name_len == 2) &&
eqi1(name + 1,
"o"))
1087 {
1089 matched = true;
1090 }
1091 break;
1092
1093 case 'x':
1094 if ((name_len == 8) &&
eqi8(name,
"x-status"))
1095 {
1096 if (e)
1097 {
1098 while (*body)
1099 {
1100 switch (*body)
1101 {
1102 case 'A':
1104 break;
1105 case 'D':
1107 break;
1108 case 'F':
1110 break;
1111 default:
1112 break;
1113 }
1114 body++;
1115 }
1116 }
1117 matched = true;
1118 }
1119 else if ((name_len == 7) &&
eqi6(name + 1,
"-label"))
1120 {
1123 matched = true;
1124 }
1125 else if ((name_len == 12) &&
eqi11(name + 1,
"-comment-to"))
1126 {
1129 matched = true;
1130 }
1131 else if ((name_len == 4) &&
eqi4(name,
"xref"))
1132 {
1135 matched = true;
1136 }
1137 else if ((name_len == 13) &&
eqi12(name + 1,
"-original-to"))
1138 {
1140 matched = true;
1141 }
1142 break;
1143
1144 default:
1145 break;
1146 }
1147
1148
1149 if (!matched && user_hdrs)
1150 {
1152 char *dup = NULL;
1154
1156 {
1158 if (do_2047)
1159 {
1161 }
1162 }
1163 else
1164 {
1166 }
1167 }
1168
1169 return matched;
1170}
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.
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.
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
#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 mailto URL, or nothing.
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 mailto URL, or nothing.
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.