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.
640{
641 if (!env || !name)
642 return 0;
643
644 bool matched = false;
645
646 switch (name[0] | 0x20)
647 {
648 case 'a':
649 if ((name_len == 13) &&
eqi12(name + 1,
"pparently-to"))
650 {
652 matched = true;
653 }
654 else if ((name_len == 15) &&
eqi14(name + 1,
"pparently-from"))
655 {
657 matched = true;
658 }
659#ifdef USE_AUTOCRYPT
660 else if ((name_len == 9) &&
eqi8(name + 1,
"utocrypt"))
661 {
663 if (c_autocrypt)
664 {
666 matched = true;
667 }
668 }
669 else if ((name_len == 16) &&
eqi15(name + 1,
"utocrypt-gossip"))
670 {
672 if (c_autocrypt)
673 {
675 matched = true;
676 }
677 }
678#endif
679 break;
680
681 case 'b':
682 if ((name_len == 3) &&
eqi2(name + 1,
"cc"))
683 {
685 matched = true;
686 }
687 break;
688
689 case 'c':
690 if ((name_len == 2) &&
eqi1(name + 1,
"c"))
691 {
693 matched = true;
694 }
695 else
696 {
697 if ((name_len >= 12) &&
eqi8(name,
"content-"))
698 {
699 if ((name_len == 12) &&
eqi4(name + 8,
"type"))
700 {
701 if (e)
703 matched = true;
704 }
705 else if ((name_len == 16) &&
eqi8(name + 8,
"language"))
706 {
707 if (e)
709 matched = true;
710 }
711 else if ((name_len == 25) &&
eqi17(name + 8,
"transfer-encoding"))
712 {
713 if (e)
715 matched = true;
716 }
717 else if ((name_len == 14) &&
eqi8(name + 6,
"t-length"))
718 {
719 if (e)
720 {
721 unsigned long len = 0;
723 }
724 matched = true;
725 }
726 else if ((name_len == 19) &&
eqi11(name + 8,
"description"))
727 {
728 if (e)
729 {
732 }
733 matched = true;
734 }
735 else if ((name_len == 19) &&
eqi11(name + 8,
"disposition"))
736 {
737 if (e)
739 matched = true;
740 }
741 }
742 }
743 break;
744
745 case 'd':
746 if ((name_len != 4) || !
eqi4(name,
"date"))
747 break;
748
750 if (e)
751 {
752 struct Tz tz = { 0 };
755 {
759 }
760 }
761 matched = true;
762 break;
763
764 case 'e':
765 if ((name_len == 7) &&
eqi6(name + 1,
"xpires") && e &&
767 {
769 }
770 break;
771
772 case 'f':
773 if ((name_len == 4) &&
eqi4(name,
"from"))
774 {
776 matched = true;
777 }
778 else if ((name_len == 11) &&
eqi10(name + 1,
"ollowup-to"))
779 {
781 {
784 }
785 matched = true;
786 }
787 break;
788
789 case 'i':
790 if ((name_len != 11) || !
eqi10(name + 1,
"n-reply-to"))
791 break;
792
795 matched = true;
796 break;
797
798 case 'l':
799 if ((name_len == 5) &&
eqi4(name + 1,
"ines"))
800 {
801 if (e)
802 {
803 unsigned int ui = 0;
806 }
807
808 matched = true;
809 }
810 else if ((name_len == 9) &&
eqi8(name + 1,
"ist-post"))
811 {
812
814 {
816 if (mailto)
817 {
821 if (c_auto_subscribe)
823 }
824 }
825 matched = true;
826 }
827 else if ((name_len == 14) &&
eqi13(name + 1,
"ist-subscribe"))
828 {
829
831 if (mailto)
832 {
835 }
836 matched = true;
837 }
838 else if ((name_len == 16) &&
eqi15(name + 1,
"ist-unsubscribe"))
839 {
840
842 if (mailto)
843 {
846 }
847 matched = true;
848 }
849 break;
850
851 case 'm':
852 if ((name_len == 12) &&
eqi11(name + 1,
"ime-version"))
853 {
854 if (e)
856 matched = true;
857 }
858 else if ((name_len == 10) &&
eqi9(name + 1,
"essage-id"))
859 {
860
863 matched = true;
864 }
865 else
866 {
867 if ((name_len >= 13) &&
eqi4(name + 1,
"ail-"))
868 {
869 if ((name_len == 13) &&
eqi8(name + 5,
"reply-to"))
870 {
871
874 matched = true;
875 }
876 else if ((name_len == 16) &&
eqi11(name + 5,
"followup-to"))
877 {
879 matched = true;
880 }
881 }
882 }
883 break;
884
885 case 'n':
886 if ((name_len == 10) &&
eqi9(name + 1,
"ewsgroups"))
887 {
891 matched = true;
892 }
893 break;
894
895 case 'o':
896
897 if ((name_len == 12) &&
eqi11(name + 1,
"rganization"))
898 {
901 }
902 break;
903
904 case 'r':
905 if ((name_len == 10) &&
eqi9(name + 1,
"eferences"))
906 {
909 matched = true;
910 }
911 else if ((name_len == 8) &&
eqi8(name,
"reply-to"))
912 {
914 matched = true;
915 }
916 else if ((name_len == 11) &&
eqi10(name + 1,
"eturn-path"))
917 {
919 matched = true;
920 }
921 else if ((name_len == 8) &&
eqi8(name,
"received"))
922 {
924 {
925 char *d = strrchr(body, ';');
926 if (d)
927 {
930 }
931 }
932 }
933 break;
934
935 case 's':
936 if ((name_len == 7) &&
eqi6(name + 1,
"ubject"))
937 {
940 matched = true;
941 }
942 else if ((name_len == 6) &&
eqi5(name + 1,
"ender"))
943 {
945 matched = true;
946 }
947 else if ((name_len == 6) &&
eqi5(name + 1,
"tatus"))
948 {
949 if (e)
950 {
951 while (*body)
952 {
953 switch (*body)
954 {
955 case 'O':
956 {
958 break;
959 }
960 case 'R':
962 break;
963 case 'r':
965 break;
966 }
967 body++;
968 }
969 }
970 matched = true;
971 }
972 else if (e && (name_len == 10) &&
eqi1(name + 1,
"u") &&
973 (
eqi8(name + 2,
"persedes") ||
eqi8(name + 2,
"percedes")))
974 {
977 }
978 break;
979
980 case 't':
981 if ((name_len == 2) &&
eqi1(name + 1,
"o"))
982 {
984 matched = true;
985 }
986 break;
987
988 case 'x':
989 if ((name_len == 8) &&
eqi8(name,
"x-status"))
990 {
991 if (e)
992 {
993 while (*body)
994 {
995 switch (*body)
996 {
997 case 'A':
999 break;
1000 case 'D':
1002 break;
1003 case 'F':
1005 break;
1006 default:
1007 break;
1008 }
1009 body++;
1010 }
1011 }
1012 matched = true;
1013 }
1014 else if ((name_len == 7) &&
eqi6(name + 1,
"-label"))
1015 {
1018 matched = true;
1019 }
1020 else if ((name_len == 12) &&
eqi11(name + 1,
"-comment-to"))
1021 {
1024 matched = true;
1025 }
1026 else if ((name_len == 4) &&
eqi4(name,
"xref"))
1027 {
1030 matched = true;
1031 }
1032 else if ((name_len == 13) &&
eqi12(name + 1,
"-original-to"))
1033 {
1035 matched = true;
1036 }
1037 break;
1038
1039 default:
1040 break;
1041 }
1042
1043
1044 if (!matched && user_hdrs)
1045 {
1047 char *dup = NULL;
1049
1051 {
1053 if (do_2047)
1054 {
1056 }
1057 }
1058 else
1059 {
1061 }
1062 }
1063
1064 return matched;
1065}
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.
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 * 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-Orig-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
char * subject
Email's subject.
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.