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.
680{
681 if (!env || !name)
682 return 0;
683
684 bool matched = false;
685
686 switch (name[0] | 0x20)
687 {
688 case 'a':
689 if ((name_len == 13) &&
eqi12(name + 1,
"pparently-to"))
690 {
692 matched = true;
693 }
694 else if ((name_len == 15) &&
eqi14(name + 1,
"pparently-from"))
695 {
697 matched = true;
698 }
699#ifdef USE_AUTOCRYPT
700 else if ((name_len == 9) &&
eqi8(name + 1,
"utocrypt"))
701 {
703 if (c_autocrypt)
704 {
706 matched = true;
707 }
708 }
709 else if ((name_len == 16) &&
eqi15(name + 1,
"utocrypt-gossip"))
710 {
712 if (c_autocrypt)
713 {
715 matched = true;
716 }
717 }
718#endif
719 break;
720
721 case 'b':
722 if ((name_len == 3) &&
eqi2(name + 1,
"cc"))
723 {
725 matched = true;
726 }
727 break;
728
729 case 'c':
730 if ((name_len == 2) &&
eqi1(name + 1,
"c"))
731 {
733 matched = true;
734 }
735 else
736 {
737 if ((name_len >= 12) &&
eqi8(name,
"content-"))
738 {
739 if ((name_len == 12) &&
eqi4(name + 8,
"type"))
740 {
741 if (e)
743 matched = true;
744 }
745 else if ((name_len == 16) &&
eqi8(name + 8,
"language"))
746 {
747 if (e)
749 matched = true;
750 }
751 else if ((name_len == 25) &&
eqi17(name + 8,
"transfer-encoding"))
752 {
753 if (e)
755 matched = true;
756 }
757 else if ((name_len == 14) &&
eqi8(name + 6,
"t-length"))
758 {
759 if (e)
760 {
761 unsigned long len = 0;
763 }
764 matched = true;
765 }
766 else if ((name_len == 19) &&
eqi11(name + 8,
"description"))
767 {
768 if (e)
769 {
772 }
773 matched = true;
774 }
775 else if ((name_len == 19) &&
eqi11(name + 8,
"disposition"))
776 {
777 if (e)
779 matched = true;
780 }
781 }
782 }
783 break;
784
785 case 'd':
786 if ((name_len != 4) || !
eqi4(name,
"date"))
787 break;
788
790 if (e)
791 {
792 struct Tz tz = { 0 };
793
796 {
800 }
801 }
802 matched = true;
803 break;
804
805 case 'e':
806 if ((name_len == 7) &&
eqi6(name + 1,
"xpires") && e)
807 {
810 {
812 }
813 }
814 break;
815
816 case 'f':
817 if ((name_len == 4) &&
eqi4(name,
"from"))
818 {
820 matched = true;
821 }
822 else if ((name_len == 11) &&
eqi10(name + 1,
"ollowup-to"))
823 {
825 {
828 }
829 matched = true;
830 }
831 break;
832
833 case 'i':
834 if ((name_len != 11) || !
eqi10(name + 1,
"n-reply-to"))
835 break;
836
842 matched = true;
843 break;
844
845 case 'l':
846 if ((name_len == 5) &&
eqi4(name + 1,
"ines"))
847 {
848 if (e)
849 {
850 unsigned int ui = 0;
853 }
854
855 matched = true;
856 }
857 else if ((name_len == 9) &&
eqi8(name + 1,
"ist-post"))
858 {
859
861 {
863 if (mailto)
864 {
868 if (c_auto_subscribe)
870 }
871 }
872 matched = true;
873 }
874 else if ((name_len == 14) &&
eqi13(name + 1,
"ist-subscribe"))
875 {
876
878 if (mailto)
879 {
882 }
883 matched = true;
884 }
885 else if ((name_len == 16) &&
eqi15(name + 1,
"ist-unsubscribe"))
886 {
887
889 if (mailto)
890 {
893 }
894 matched = true;
895 }
896 break;
897
898 case 'm':
899 if ((name_len == 12) &&
eqi11(name + 1,
"ime-version"))
900 {
901 if (e)
903 matched = true;
904 }
905 else if ((name_len == 10) &&
eqi9(name + 1,
"essage-id"))
906 {
907
910 matched = true;
911 }
912 else
913 {
914 if ((name_len >= 13) &&
eqi4(name + 1,
"ail-"))
915 {
916 if ((name_len == 13) &&
eqi8(name + 5,
"reply-to"))
917 {
918
921 matched = true;
922 }
923 else if ((name_len == 16) &&
eqi11(name + 5,
"followup-to"))
924 {
926 matched = true;
927 }
928 }
929 }
930 break;
931
932 case 'n':
933 if ((name_len == 10) &&
eqi9(name + 1,
"ewsgroups"))
934 {
938 matched = true;
939 }
940 break;
941
942 case 'o':
943
944 if ((name_len == 12) &&
eqi11(name + 1,
"rganization"))
945 {
948 }
949 break;
950
951 case 'r':
952 if ((name_len == 10) &&
eqi9(name + 1,
"eferences"))
953 {
956 matched = true;
957 }
958 else if ((name_len == 8) &&
eqi8(name,
"reply-to"))
959 {
961 matched = true;
962 }
963 else if ((name_len == 11) &&
eqi10(name + 1,
"eturn-path"))
964 {
966 matched = true;
967 }
968 else if ((name_len == 8) &&
eqi8(name,
"received"))
969 {
971 {
972 char *d = strrchr(body, ';');
973 if (d)
974 {
976
978 }
979 }
980 }
981 break;
982
983 case 's':
984 if ((name_len == 7) &&
eqi6(name + 1,
"ubject"))
985 {
988 matched = true;
989 }
990 else if ((name_len == 6) &&
eqi5(name + 1,
"ender"))
991 {
993 matched = true;
994 }
995 else if ((name_len == 6) &&
eqi5(name + 1,
"tatus"))
996 {
997 if (e)
998 {
999 while (*body)
1000 {
1001 switch (*body)
1002 {
1003 case 'O':
1004 {
1006 break;
1007 }
1008 case 'R':
1010 break;
1011 case 'r':
1013 break;
1014 }
1015 body++;
1016 }
1017 }
1018 matched = true;
1019 }
1020 else if (e && (name_len == 10) &&
eqi1(name + 1,
"u") &&
1021 (
eqi8(name + 2,
"persedes") ||
eqi8(name + 2,
"percedes")))
1022 {
1025 }
1026 break;
1027
1028 case 't':
1029 if ((name_len == 2) &&
eqi1(name + 1,
"o"))
1030 {
1032 matched = true;
1033 }
1034 break;
1035
1036 case 'x':
1037 if ((name_len == 8) &&
eqi8(name,
"x-status"))
1038 {
1039 if (e)
1040 {
1041 while (*body)
1042 {
1043 switch (*body)
1044 {
1045 case 'A':
1047 break;
1048 case 'D':
1050 break;
1051 case 'F':
1053 break;
1054 default:
1055 break;
1056 }
1057 body++;
1058 }
1059 }
1060 matched = true;
1061 }
1062 else if ((name_len == 7) &&
eqi6(name + 1,
"-label"))
1063 {
1066 matched = true;
1067 }
1068 else if ((name_len == 12) &&
eqi11(name + 1,
"-comment-to"))
1069 {
1072 matched = true;
1073 }
1074 else if ((name_len == 4) &&
eqi4(name,
"xref"))
1075 {
1078 matched = true;
1079 }
1080 else if ((name_len == 13) &&
eqi12(name + 1,
"-original-to"))
1081 {
1083 matched = true;
1084 }
1085 break;
1086
1087 default:
1088 break;
1089 }
1090
1091
1092 if (!matched && user_hdrs)
1093 {
1095 char *dup = NULL;
1097
1099 {
1101 if (do_2047)
1102 {
1104 }
1105 }
1106 else
1107 {
1109 }
1110 }
1111
1112 return matched;
1113}
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.