Lines 55-60
Link Here
|
55 |
int Slrn_Use_Meta_Mail = 1; |
55 |
int Slrn_Use_Meta_Mail = 1; |
56 |
int Slrn_Fold_Headers = 1; |
56 |
int Slrn_Fold_Headers = 1; |
57 |
char *Slrn_MetaMail_Cmd; |
57 |
char *Slrn_MetaMail_Cmd; |
|
|
58 |
int Slrn_Minimal_Multipart =1; |
58 |
|
59 |
|
59 |
#ifndef SLRNPULL_CODE |
60 |
#ifndef SLRNPULL_CODE |
60 |
#define CONTENT_TYPE_TEXT 0x01 |
61 |
#define CONTENT_TYPE_TEXT 0x01 |
Lines 106-122
Link Here
|
106 |
} |
107 |
} |
107 |
b += 5; |
108 |
b += 5; |
108 |
} |
109 |
} |
109 |
else if (0 == slrn_case_strncmp (b, "message/", 5)) |
110 |
else if (0 == slrn_case_strncmp (b, "message/", 8)) |
110 |
{ |
111 |
{ |
111 |
a->mime.content_type = CONTENT_TYPE_MESSAGE; |
112 |
a->mime.content_type = CONTENT_TYPE_MESSAGE; |
112 |
a->mime.content_subtype = CONTENT_SUBTYPE_UNKNOWN; |
113 |
a->mime.content_subtype = CONTENT_SUBTYPE_UNKNOWN; |
113 |
b += 8; |
114 |
b += 8; |
114 |
} |
115 |
} |
115 |
else if (0 == slrn_case_strncmp (b, "multipart/", 5)) |
116 |
else if (0 == slrn_case_strncmp (b, "application/", 12)) |
|
|
117 |
{ |
118 |
b += 12; |
119 |
if (0 != slrn_case_strncmp (b, "pgp-signature", 13)) |
120 |
{ |
121 |
a->mime.content_type = CONTENT_TYPE_UNSUPPORTED; |
122 |
a->mime.content_subtype = CONTENT_SUBTYPE_UNSUPPORTED; |
123 |
return -1; |
124 |
} |
125 |
a->mime.content_type = CONTENT_TYPE_TEXT; |
126 |
a->mime.content_subtype = CONTENT_SUBTYPE_PLAIN; |
127 |
} |
128 |
else if (0 == slrn_case_strncmp (b, "multipart/", 10)) |
116 |
{ |
129 |
{ |
117 |
a->mime.content_type = CONTENT_TYPE_MULTIPART; |
130 |
a->mime.content_type = CONTENT_TYPE_MULTIPART; |
118 |
a->mime.content_subtype = CONTENT_SUBTYPE_UNKNOWN; |
131 |
a->mime.content_subtype = CONTENT_SUBTYPE_UNKNOWN; |
119 |
b += 10; |
132 |
b += 10; |
|
|
133 |
while (NULL != (b = slrn_strbyte(b, ';'))) |
134 |
{ |
135 |
char *boundary; |
136 |
unsigned int len; |
137 |
|
138 |
b = slrn_skip_whitespace (b + 1); |
139 |
|
140 |
if (0 != slrn_case_strncmp (b, "boundary", 8)) |
141 |
continue; |
142 |
|
143 |
b = slrn_skip_whitespace (b + 8); |
144 |
|
145 |
if (*b != '=') continue; |
146 |
b++; |
147 |
if (*b == '"') b++; |
148 |
boundary = b; |
149 |
while (*b && (*b != ';') |
150 |
&& (*b != ' ') && (*b != '\t') && (*b != '\n') |
151 |
&& (*b != '"')) |
152 |
b++; |
153 |
len = b - boundary; |
154 |
|
155 |
/* add a "--" at the start of boundary */ |
156 |
a->mime.boundary = slrn_safe_malloc(len+5); |
157 |
a->mime.boundary[0]='-'; |
158 |
a->mime.boundary[1]='-'; |
159 |
slrn_strncpy(a->mime.boundary+2, boundary, len+1); |
160 |
a->mime.boundary[len+2]='-'; |
161 |
a->mime.boundary[len+3]='-'; |
162 |
return 0; |
163 |
} |
120 |
} |
164 |
} |
121 |
else |
165 |
else |
122 |
{ |
166 |
{ |
Lines 786-791
Link Here
|
786 |
m->was_parsed = 0; |
830 |
m->was_parsed = 0; |
787 |
m->needs_metamail = 0; |
831 |
m->needs_metamail = 0; |
788 |
m->charset = NULL; |
832 |
m->charset = NULL; |
|
|
833 |
m->boundary = NULL; |
789 |
m->content_type = 0; |
834 |
m->content_type = 0; |
790 |
m->content_subtype = 0; |
835 |
m->content_subtype = 0; |
791 |
} |
836 |
} |
Lines 798-803
Link Here
|
798 |
{ |
843 |
{ |
799 |
slrn_free(m->charset); |
844 |
slrn_free(m->charset); |
800 |
} |
845 |
} |
|
|
846 |
if (m->boundary != NULL) |
847 |
{ |
848 |
slrn_free(m->boundary); |
849 |
} |
801 |
} |
850 |
} |
802 |
|
851 |
|
803 |
/*}}}*/ |
852 |
/*}}}*/ |
Lines 883-889
Link Here
|
883 |
obj=tmp; |
932 |
obj=tmp; |
884 |
} |
933 |
} |
885 |
} |
934 |
} |
|
|
935 |
/*}}}*/ |
886 |
|
936 |
|
|
|
937 |
int slrn_convert_multipart_article(Slrn_Article_Type *a, char *to_charset)/*{{{*/ |
938 |
{ |
939 |
struct Slrn_Article_Line_Type *line, *first_line, *line_start_part, *line_end_part, *line_tmp; |
940 |
int len; |
941 |
int j=1; |
942 |
int endfound=0; |
943 |
|
944 |
Slrn_Mime_Type mime_bak; |
945 |
|
946 |
first_line =a->lines; |
947 |
line =a->lines; |
948 |
len = strlen(a->mime.boundary)-2; |
949 |
/* search 1st boundary */ |
950 |
do |
951 |
{ |
952 |
if((line->flags & HEADER_LINE) == 0) |
953 |
{ |
954 |
line->flags |= HIDDEN_LINE; |
955 |
} |
956 |
line=line->next; |
957 |
} while ((line->next != NULL) && slrn_case_strncmp(line->buf, a->mime.boundary, len) != 0); |
958 |
|
959 |
while ((line->next != NULL) && (endfound == 0)) |
960 |
{ |
961 |
j++; |
962 |
line_start_part = line; |
963 |
do |
964 |
{ |
965 |
line->flags |= HIDDEN_LINE; |
966 |
line->flags |= HEADER_LINE; |
967 |
line=line->next; |
968 |
|
969 |
} while ((line->next != NULL) && (*(line->buf) != 0)); |
970 |
|
971 |
/* search boundary */ |
972 |
while ((line->next != NULL) && (slrn_case_strncmp(line->buf, a->mime.boundary, len) != 0)) |
973 |
{ |
974 |
line_end_part=line; |
975 |
line=line->next; |
976 |
} |
977 |
if(slrn_case_strncmp(line->buf, a->mime.boundary, len+2) == 0) |
978 |
{ |
979 |
/* we found the normal ending boundary */ |
980 |
endfound=1; |
981 |
} |
982 |
else if(line->next==NULL) |
983 |
{ |
984 |
/* end of article, indicating a corrupted article */ |
985 |
endfound=2; |
986 |
} |
987 |
|
988 |
/* pseudo article with only multipart */ |
989 |
mime_bak = a->mime; |
990 |
slrn_mime_init(&a->mime); |
991 |
a->lines = line_start_part; |
992 |
|
993 |
/* start of pseudo article has no prev, save old prev value in line_start_part */ |
994 |
line_start_part=line_start_part->prev; |
995 |
a->lines->prev = NULL; |
996 |
|
997 |
if(endfound != 2) |
998 |
{ |
999 |
line_end_part->next = NULL; |
1000 |
} |
1001 |
|
1002 |
_slrn_art_unfold_header_lines(a); |
1003 |
slrn_mime_process_article (a); |
1004 |
|
1005 |
line->flags |= HIDDEN_LINE; |
1006 |
line_tmp = a->lines; |
1007 |
do |
1008 |
{ |
1009 |
if( line_tmp->flags & HEADER_LINE) |
1010 |
{ |
1011 |
line_tmp->flags ^= HEADER_LINE; |
1012 |
} |
1013 |
else if(a->mime.content_type == CONTENT_TYPE_UNSUPPORTED) |
1014 |
{ |
1015 |
/* hide not supported multiparts */ |
1016 |
line_tmp->flags |= HIDDEN_LINE; |
1017 |
} |
1018 |
line_end_part=line_tmp; |
1019 |
line_tmp=line_tmp->next; |
1020 |
} while (line_tmp != NULL); |
1021 |
|
1022 |
/* set back article */ |
1023 |
line_start_part->next=a->lines; |
1024 |
a->lines->prev=line_start_part; |
1025 |
|
1026 |
a->lines = first_line; |
1027 |
if(endfound != 2) |
1028 |
{ |
1029 |
line_end_part->next = line; |
1030 |
line->prev = line_end_part; |
1031 |
} |
1032 |
else |
1033 |
{ |
1034 |
slrn_message (_("Multipart article is corrupted.")); |
1035 |
} |
1036 |
|
1037 |
if(a->mime.content_type == CONTENT_TYPE_UNSUPPORTED) |
1038 |
slrn_message (_("Unsupported multiparts were hidden.")); |
1039 |
|
1040 |
/* free space */ |
1041 |
slrn_mime_free(&a->mime); |
1042 |
|
1043 |
a->mime=mime_bak; |
1044 |
} |
1045 |
return 0; |
1046 |
} |
887 |
/*}}}*/ |
1047 |
/*}}}*/ |
888 |
|
1048 |
|
889 |
static char *guess_body_charset (Slrn_Article_Type *a) |
1049 |
static char *guess_body_charset (Slrn_Article_Type *a) |
Lines 938-950
Link Here
|
938 |
a->mime.needs_metamail = 1; |
1098 |
a->mime.needs_metamail = 1; |
939 |
return 0; |
1099 |
return 0; |
940 |
} |
1100 |
} |
941 |
|
1101 |
|
942 |
if ((a->mime.charset == NULL) |
1102 |
if ((a->mime.charset == NULL) |
943 |
&& (NULL == (a->mime.charset = guess_body_charset (a)))) |
1103 |
&& (NULL == (a->mime.charset = guess_body_charset (a)))) |
944 |
return -1; |
1104 |
return -1; |
945 |
|
1105 |
|
946 |
rfc1522_decode_headers (a); |
1106 |
rfc1522_decode_headers (a); |
947 |
|
1107 |
|
|
|
1108 |
if ((a->mime.content_type == CONTENT_TYPE_MULTIPART) && (Slrn_Minimal_Multipart != 0) ) |
1109 |
{ |
1110 |
return slrn_convert_multipart_article(a, Slrn_Display_Charset); |
1111 |
} |
1112 |
|
948 |
switch (parse_content_transfer_encoding_line (a)) |
1113 |
switch (parse_content_transfer_encoding_line (a)) |
949 |
{ |
1114 |
{ |
950 |
case ENCODED_RAW: |
1115 |
case ENCODED_RAW: |