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 };
794
797 {
801 }
802 }
803 matched = true;
804 break;
805
806 case 'e':
807 if ((name_len == 7) &&
eqi6(name + 1,
"xpires") && e)
808 {
811 {
813 }
814 }
815 break;
816
817 case 'f':
818 if ((name_len == 4) &&
eqi4(name,
"from"))
819 {
821 matched = true;
822 }
823 else if ((name_len == 11) &&
eqi10(name + 1,
"ollowup-to"))
824 {
826 {
829 }
830 matched = true;
831 }
832 break;
833
834 case 'i':
835 if ((name_len != 11) || !
eqi10(name + 1,
"n-reply-to"))
836 break;
837
843 matched = true;
844 break;
845
846 case 'l':
847 if ((name_len == 5) &&
eqi4(name + 1,
"ines"))
848 {
849 if (e)
850 {
851 unsigned int ui = 0;
854 }
855
856 matched = true;
857 }
858 else if ((name_len == 9) &&
eqi8(name + 1,
"ist-post"))
859 {
860
862 {
864 if (mailto)
865 {
869 if (c_auto_subscribe)
871 }
872 }
873 matched = true;
874 }
875 else if ((name_len == 14) &&
eqi13(name + 1,
"ist-subscribe"))
876 {
877
879 if (mailto)
880 {
883 }
884 matched = true;
885 }
886 else if ((name_len == 16) &&
eqi15(name + 1,
"ist-unsubscribe"))
887 {
888
890 if (mailto)
891 {
894 }
895 matched = true;
896 }
897 break;
898
899 case 'm':
900 if ((name_len == 12) &&
eqi11(name + 1,
"ime-version"))
901 {
902 if (e)
904 matched = true;
905 }
906 else if ((name_len == 10) &&
eqi9(name + 1,
"essage-id"))
907 {
908
911 matched = true;
912 }
913 else
914 {
915 if ((name_len >= 13) &&
eqi4(name + 1,
"ail-"))
916 {
917 if ((name_len == 13) &&
eqi8(name + 5,
"reply-to"))
918 {
919
922 matched = true;
923 }
924 else if ((name_len == 16) &&
eqi11(name + 5,
"followup-to"))
925 {
927 matched = true;
928 }
929 }
930 }
931 break;
932
933 case 'n':
934 if ((name_len == 10) &&
eqi9(name + 1,
"ewsgroups"))
935 {
939 matched = true;
940 }
941 break;
942
943 case 'o':
944
945 if ((name_len == 12) &&
eqi11(name + 1,
"rganization"))
946 {
949 }
950 break;
951
952 case 'r':
953 if ((name_len == 10) &&
eqi9(name + 1,
"eferences"))
954 {
957 matched = true;
958 }
959 else if ((name_len == 8) &&
eqi8(name,
"reply-to"))
960 {
962 matched = true;
963 }
964 else if ((name_len == 11) &&
eqi10(name + 1,
"eturn-path"))
965 {
967 matched = true;
968 }
969 else if ((name_len == 8) &&
eqi8(name,
"received"))
970 {
972 {
973 char *d = strrchr(body, ';');
974 if (d)
975 {
977
979 }
980 }
981 }
982 break;
983
984 case 's':
985 if ((name_len == 7) &&
eqi6(name + 1,
"ubject"))
986 {
989 matched = true;
990 }
991 else if ((name_len == 6) &&
eqi5(name + 1,
"ender"))
992 {
994 matched = true;
995 }
996 else if ((name_len == 6) &&
eqi5(name + 1,
"tatus"))
997 {
998 if (e)
999 {
1000 while (*body)
1001 {
1002 switch (*body)
1003 {
1004 case 'O':
1005 {
1007 break;
1008 }
1009 case 'R':
1011 break;
1012 case 'r':
1014 break;
1015 }
1016 body++;
1017 }
1018 }
1019 matched = true;
1020 }
1021 else if (e && (name_len == 10) &&
eqi1(name + 1,
"u") &&
1022 (
eqi8(name + 2,
"persedes") ||
eqi8(name + 2,
"percedes")))
1023 {
1026 }
1027 break;
1028
1029 case 't':
1030 if ((name_len == 2) &&
eqi1(name + 1,
"o"))
1031 {
1033 matched = true;
1034 }
1035 break;
1036
1037 case 'x':
1038 if ((name_len == 8) &&
eqi8(name,
"x-status"))
1039 {
1040 if (e)
1041 {
1042 while (*body)
1043 {
1044 switch (*body)
1045 {
1046 case 'A':
1048 break;
1049 case 'D':
1051 break;
1052 case 'F':
1054 break;
1055 default:
1056 break;
1057 }
1058 body++;
1059 }
1060 }
1061 matched = true;
1062 }
1063 else if ((name_len == 7) &&
eqi6(name + 1,
"-label"))
1064 {
1067 matched = true;
1068 }
1069 else if ((name_len == 12) &&
eqi11(name + 1,
"-comment-to"))
1070 {
1073 matched = true;
1074 }
1075 else if ((name_len == 4) &&
eqi4(name,
"xref"))
1076 {
1079 matched = true;
1080 }
1081 else if ((name_len == 13) &&
eqi12(name + 1,
"-original-to"))
1082 {
1084 matched = true;
1085 }
1086 break;
1087
1088 default:
1089 break;
1090 }
1091
1092
1093 if (!matched && user_hdrs)
1094 {
1096 char *dup = NULL;
1098
1100 {
1102 if (do_2047)
1103 {
1105 }
1106 }
1107 else
1108 {
1110 }
1111 }
1112
1113 return matched;
1114}
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.