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.
681{
682 if (!env || !name)
683 return 0;
684
685 bool matched = false;
686
687 switch (name[0] | 0x20)
688 {
689 case 'a':
690 if ((name_len == 13) &&
eqi12(name + 1,
"pparently-to"))
691 {
693 matched = true;
694 }
695 else if ((name_len == 15) &&
eqi14(name + 1,
"pparently-from"))
696 {
698 matched = true;
699 }
700#ifdef USE_AUTOCRYPT
701 else if ((name_len == 9) &&
eqi8(name + 1,
"utocrypt"))
702 {
704 if (c_autocrypt)
705 {
707 matched = true;
708 }
709 }
710 else if ((name_len == 16) &&
eqi15(name + 1,
"utocrypt-gossip"))
711 {
713 if (c_autocrypt)
714 {
716 matched = true;
717 }
718 }
719#endif
720 break;
721
722 case 'b':
723 if ((name_len == 3) &&
eqi2(name + 1,
"cc"))
724 {
726 matched = true;
727 }
728 break;
729
730 case 'c':
731 if ((name_len == 2) &&
eqi1(name + 1,
"c"))
732 {
734 matched = true;
735 }
736 else
737 {
738 if ((name_len >= 12) &&
eqi8(name,
"content-"))
739 {
740 if ((name_len == 12) &&
eqi4(name + 8,
"type"))
741 {
742 if (e)
744 matched = true;
745 }
746 else if ((name_len == 16) &&
eqi8(name + 8,
"language"))
747 {
748 if (e)
750 matched = true;
751 }
752 else if ((name_len == 25) &&
eqi17(name + 8,
"transfer-encoding"))
753 {
754 if (e)
756 matched = true;
757 }
758 else if ((name_len == 14) &&
eqi8(name + 6,
"t-length"))
759 {
760 if (e)
761 {
762 unsigned long len = 0;
764 }
765 matched = true;
766 }
767 else if ((name_len == 19) &&
eqi11(name + 8,
"description"))
768 {
769 if (e)
770 {
773 }
774 matched = true;
775 }
776 else if ((name_len == 19) &&
eqi11(name + 8,
"disposition"))
777 {
778 if (e)
780 matched = true;
781 }
782 }
783 }
784 break;
785
786 case 'd':
787 if ((name_len != 4) || !
eqi4(name,
"date"))
788 break;
789
791 if (e)
792 {
793 struct Tz tz = { 0 };
796 {
800 }
801 }
802 matched = true;
803 break;
804
805 case 'e':
806 if ((name_len == 7) &&
eqi6(name + 1,
"xpires") && e &&
808 {
810 }
811 break;
812
813 case 'f':
814 if ((name_len == 4) &&
eqi4(name,
"from"))
815 {
817 matched = true;
818 }
819 else if ((name_len == 11) &&
eqi10(name + 1,
"ollowup-to"))
820 {
822 {
825 }
826 matched = true;
827 }
828 break;
829
830 case 'i':
831 if ((name_len != 11) || !
eqi10(name + 1,
"n-reply-to"))
832 break;
833
839 matched = true;
840 break;
841
842 case 'l':
843 if ((name_len == 5) &&
eqi4(name + 1,
"ines"))
844 {
845 if (e)
846 {
847 unsigned int ui = 0;
850 }
851
852 matched = true;
853 }
854 else if ((name_len == 9) &&
eqi8(name + 1,
"ist-post"))
855 {
856
858 {
860 if (mailto)
861 {
865 if (c_auto_subscribe)
867 }
868 }
869 matched = true;
870 }
871 else if ((name_len == 14) &&
eqi13(name + 1,
"ist-subscribe"))
872 {
873
875 if (mailto)
876 {
879 }
880 matched = true;
881 }
882 else if ((name_len == 16) &&
eqi15(name + 1,
"ist-unsubscribe"))
883 {
884
886 if (mailto)
887 {
890 }
891 matched = true;
892 }
893 break;
894
895 case 'm':
896 if ((name_len == 12) &&
eqi11(name + 1,
"ime-version"))
897 {
898 if (e)
900 matched = true;
901 }
902 else if ((name_len == 10) &&
eqi9(name + 1,
"essage-id"))
903 {
904
907 matched = true;
908 }
909 else
910 {
911 if ((name_len >= 13) &&
eqi4(name + 1,
"ail-"))
912 {
913 if ((name_len == 13) &&
eqi8(name + 5,
"reply-to"))
914 {
915
918 matched = true;
919 }
920 else if ((name_len == 16) &&
eqi11(name + 5,
"followup-to"))
921 {
923 matched = true;
924 }
925 }
926 }
927 break;
928
929 case 'n':
930 if ((name_len == 10) &&
eqi9(name + 1,
"ewsgroups"))
931 {
935 matched = true;
936 }
937 break;
938
939 case 'o':
940
941 if ((name_len == 12) &&
eqi11(name + 1,
"rganization"))
942 {
945 }
946 break;
947
948 case 'r':
949 if ((name_len == 10) &&
eqi9(name + 1,
"eferences"))
950 {
953 matched = true;
954 }
955 else if ((name_len == 8) &&
eqi8(name,
"reply-to"))
956 {
958 matched = true;
959 }
960 else if ((name_len == 11) &&
eqi10(name + 1,
"eturn-path"))
961 {
963 matched = true;
964 }
965 else if ((name_len == 8) &&
eqi8(name,
"received"))
966 {
968 {
969 char *d = strrchr(body, ';');
970 if (d)
971 {
974 }
975 }
976 }
977 break;
978
979 case 's':
980 if ((name_len == 7) &&
eqi6(name + 1,
"ubject"))
981 {
984 matched = true;
985 }
986 else if ((name_len == 6) &&
eqi5(name + 1,
"ender"))
987 {
989 matched = true;
990 }
991 else if ((name_len == 6) &&
eqi5(name + 1,
"tatus"))
992 {
993 if (e)
994 {
995 while (*body)
996 {
997 switch (*body)
998 {
999 case 'O':
1000 {
1002 break;
1003 }
1004 case 'R':
1006 break;
1007 case 'r':
1009 break;
1010 }
1011 body++;
1012 }
1013 }
1014 matched = true;
1015 }
1016 else if (e && (name_len == 10) &&
eqi1(name + 1,
"u") &&
1017 (
eqi8(name + 2,
"persedes") ||
eqi8(name + 2,
"percedes")))
1018 {
1021 }
1022 break;
1023
1024 case 't':
1025 if ((name_len == 2) &&
eqi1(name + 1,
"o"))
1026 {
1028 matched = true;
1029 }
1030 break;
1031
1032 case 'x':
1033 if ((name_len == 8) &&
eqi8(name,
"x-status"))
1034 {
1035 if (e)
1036 {
1037 while (*body)
1038 {
1039 switch (*body)
1040 {
1041 case 'A':
1043 break;
1044 case 'D':
1046 break;
1047 case 'F':
1049 break;
1050 default:
1051 break;
1052 }
1053 body++;
1054 }
1055 }
1056 matched = true;
1057 }
1058 else if ((name_len == 7) &&
eqi6(name + 1,
"-label"))
1059 {
1062 matched = true;
1063 }
1064 else if ((name_len == 12) &&
eqi11(name + 1,
"-comment-to"))
1065 {
1068 matched = true;
1069 }
1070 else if ((name_len == 4) &&
eqi4(name,
"xref"))
1071 {
1074 matched = true;
1075 }
1076 else if ((name_len == 13) &&
eqi12(name + 1,
"-original-to"))
1077 {
1079 matched = true;
1080 }
1081 break;
1082
1083 default:
1084 break;
1085 }
1086
1087
1088 if (!matched && user_hdrs)
1089 {
1091 char *dup = NULL;
1093
1095 {
1097 if (do_2047)
1098 {
1100 }
1101 }
1102 else
1103 {
1105 }
1106 }
1107
1108 return matched;
1109}
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.
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.
void mutt_auto_subscribe(const char *mailto)
Check if user is subscribed to mailing 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 char * rfc2369_first_mailto(const char *body)
Extract the first mailto: URL from a RFC2369 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.
void mutt_filter_commandline_header_value(char *header)
Sanitise characters in a header value.
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 eqi9(const char *a, const char b[9])
eqi9 - Compare two 9-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons
static bool eqi10(const char *a, const char b[10])
eqi10 - Compare two 10-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 eqi14(const char *a, const char b[14])
eqi14 - Compare two 14-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 eqi12(const char *a, const char b[12])
eqi12 - Compare two 12-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.
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 * mutt_str_skip_whitespace(const char *p)
Find the first non-whitespace character in a string.
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 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.
Container for Accounts, Notifications.
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.