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.
648{
649 if (!env || !name)
650 return 0;
651
652 bool matched = false;
653
654 switch (name[0] | 0x20)
655 {
656 case 'a':
657 if ((name_len == 13) &&
eqi12(name + 1,
"pparently-to"))
658 {
660 matched = true;
661 }
662 else if ((name_len == 15) &&
eqi14(name + 1,
"pparently-from"))
663 {
665 matched = true;
666 }
667#ifdef USE_AUTOCRYPT
668 else if ((name_len == 9) &&
eqi8(name + 1,
"utocrypt"))
669 {
671 if (c_autocrypt)
672 {
674 matched = true;
675 }
676 }
677 else if ((name_len == 16) &&
eqi15(name + 1,
"utocrypt-gossip"))
678 {
680 if (c_autocrypt)
681 {
683 matched = true;
684 }
685 }
686#endif
687 break;
688
689 case 'b':
690 if ((name_len == 3) &&
eqi2(name + 1,
"cc"))
691 {
693 matched = true;
694 }
695 break;
696
697 case 'c':
698 if ((name_len == 2) &&
eqi1(name + 1,
"c"))
699 {
701 matched = true;
702 }
703 else
704 {
705 if ((name_len >= 12) &&
eqi8(name,
"content-"))
706 {
707 if ((name_len == 12) &&
eqi4(name + 8,
"type"))
708 {
709 if (e)
711 matched = true;
712 }
713 else if ((name_len == 16) &&
eqi8(name + 8,
"language"))
714 {
715 if (e)
717 matched = true;
718 }
719 else if ((name_len == 25) &&
eqi17(name + 8,
"transfer-encoding"))
720 {
721 if (e)
723 matched = true;
724 }
725 else if ((name_len == 14) &&
eqi8(name + 6,
"t-length"))
726 {
727 if (e)
728 {
729 unsigned long len = 0;
731 }
732 matched = true;
733 }
734 else if ((name_len == 19) &&
eqi11(name + 8,
"description"))
735 {
736 if (e)
737 {
740 }
741 matched = true;
742 }
743 else if ((name_len == 19) &&
eqi11(name + 8,
"disposition"))
744 {
745 if (e)
747 matched = true;
748 }
749 }
750 }
751 break;
752
753 case 'd':
754 if ((name_len != 4) || !
eqi4(name,
"date"))
755 break;
756
758 if (e)
759 {
760 struct Tz tz = { 0 };
761
764 {
768 }
769 }
770 matched = true;
771 break;
772
773 case 'e':
774 if ((name_len == 7) &&
eqi6(name + 1,
"xpires") && e)
775 {
778 {
780 }
781 }
782 break;
783
784 case 'f':
785 if ((name_len == 4) &&
eqi4(name,
"from"))
786 {
788 matched = true;
789 }
790 else if ((name_len == 11) &&
eqi10(name + 1,
"ollowup-to"))
791 {
793 {
796 }
797 matched = true;
798 }
799 break;
800
801 case 'i':
802 if ((name_len != 11) || !
eqi10(name + 1,
"n-reply-to"))
803 break;
804
810 matched = true;
811 break;
812
813 case 'l':
814 if ((name_len == 5) &&
eqi4(name + 1,
"ines"))
815 {
816 if (e)
817 {
818 unsigned int ui = 0;
821 }
822
823 matched = true;
824 }
825 else if ((name_len == 9) &&
eqi8(name + 1,
"ist-post"))
826 {
827
829 {
831 if (mailto)
832 {
836 if (c_auto_subscribe)
838 }
839 }
840 matched = true;
841 }
842 else if ((name_len == 14) &&
eqi13(name + 1,
"ist-subscribe"))
843 {
844
846 if (mailto)
847 {
850 }
851 matched = true;
852 }
853 else if ((name_len == 16) &&
eqi15(name + 1,
"ist-unsubscribe"))
854 {
855
857 if (mailto)
858 {
861 }
862 matched = true;
863 }
864 break;
865
866 case 'm':
867 if ((name_len == 12) &&
eqi11(name + 1,
"ime-version"))
868 {
869 if (e)
871 matched = true;
872 }
873 else if ((name_len == 10) &&
eqi9(name + 1,
"essage-id"))
874 {
875
878 matched = true;
879 }
880 else
881 {
882 if ((name_len >= 13) &&
eqi4(name + 1,
"ail-"))
883 {
884 if ((name_len == 13) &&
eqi8(name + 5,
"reply-to"))
885 {
886
889 matched = true;
890 }
891 else if ((name_len == 16) &&
eqi11(name + 5,
"followup-to"))
892 {
894 matched = true;
895 }
896 }
897 }
898 break;
899
900 case 'n':
901 if ((name_len == 10) &&
eqi9(name + 1,
"ewsgroups"))
902 {
906 matched = true;
907 }
908 break;
909
910 case 'o':
911
912 if ((name_len == 12) &&
eqi11(name + 1,
"rganization"))
913 {
916 }
917 break;
918
919 case 'r':
920 if ((name_len == 10) &&
eqi9(name + 1,
"eferences"))
921 {
924 matched = true;
925 }
926 else if ((name_len == 8) &&
eqi8(name,
"reply-to"))
927 {
929 matched = true;
930 }
931 else if ((name_len == 11) &&
eqi10(name + 1,
"eturn-path"))
932 {
934 matched = true;
935 }
936 else if ((name_len == 8) &&
eqi8(name,
"received"))
937 {
939 {
940 char *d = strrchr(body, ';');
941 if (d)
942 {
944
946 }
947 }
948 }
949 break;
950
951 case 's':
952 if ((name_len == 7) &&
eqi6(name + 1,
"ubject"))
953 {
956 matched = true;
957 }
958 else if ((name_len == 6) &&
eqi5(name + 1,
"ender"))
959 {
961 matched = true;
962 }
963 else if ((name_len == 6) &&
eqi5(name + 1,
"tatus"))
964 {
965 if (e)
966 {
967 while (*body)
968 {
969 switch (*body)
970 {
971 case 'O':
972 {
974 break;
975 }
976 case 'R':
978 break;
979 case 'r':
981 break;
982 }
983 body++;
984 }
985 }
986 matched = true;
987 }
988 else if (e && (name_len == 10) &&
eqi1(name + 1,
"u") &&
989 (
eqi8(name + 2,
"persedes") ||
eqi8(name + 2,
"percedes")))
990 {
993 }
994 break;
995
996 case 't':
997 if ((name_len == 2) &&
eqi1(name + 1,
"o"))
998 {
1000 matched = true;
1001 }
1002 break;
1003
1004 case 'x':
1005 if ((name_len == 8) &&
eqi8(name,
"x-status"))
1006 {
1007 if (e)
1008 {
1009 while (*body)
1010 {
1011 switch (*body)
1012 {
1013 case 'A':
1015 break;
1016 case 'D':
1018 break;
1019 case 'F':
1021 break;
1022 default:
1023 break;
1024 }
1025 body++;
1026 }
1027 }
1028 matched = true;
1029 }
1030 else if ((name_len == 7) &&
eqi6(name + 1,
"-label"))
1031 {
1034 matched = true;
1035 }
1036 else if ((name_len == 12) &&
eqi11(name + 1,
"-comment-to"))
1037 {
1040 matched = true;
1041 }
1042 else if ((name_len == 4) &&
eqi4(name,
"xref"))
1043 {
1046 matched = true;
1047 }
1048 else if ((name_len == 13) &&
eqi12(name + 1,
"-original-to"))
1049 {
1051 matched = true;
1052 }
1053 break;
1054
1055 default:
1056 break;
1057 }
1058
1059
1060 if (!matched && user_hdrs)
1061 {
1063 char *dup = NULL;
1065
1067 {
1069 if (do_2047)
1070 {
1072 }
1073 }
1074 else
1075 {
1077 }
1078 }
1079
1080 return matched;
1081}
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.
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.
void mutt_parse_content_type(const char *s, struct Body *b)
Parse a content type.
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.
#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 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.
#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.
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.
struct AddressList to
Email's 'To' list.
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.