author | zautrix <zautrix> | 2004-11-06 23:30:02 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-11-06 23:30:02 (UTC) |
commit | 023e0e82dd8bf6421d12492a2dd25534fc43ad31 (patch) (unidiff) | |
tree | cf0533e3ccc642cb57a41953f184f457fa5365ba /kmicromail/libetpan | |
parent | f8841c92d5251f713eb7a025af8fdee52de45b3d (diff) | |
download | kdepimpi-023e0e82dd8bf6421d12492a2dd25534fc43ad31.zip kdepimpi-023e0e82dd8bf6421d12492a2dd25534fc43ad31.tar.gz kdepimpi-023e0e82dd8bf6421d12492a2dd25534fc43ad31.tar.bz2 |
many ompi fixes
-rw-r--r-- | kmicromail/libetpan/mime/mailmime_decode.c | 203 |
1 files changed, 109 insertions, 94 deletions
diff --git a/kmicromail/libetpan/mime/mailmime_decode.c b/kmicromail/libetpan/mime/mailmime_decode.c index dbaeb68..b2ab0f7 100644 --- a/kmicromail/libetpan/mime/mailmime_decode.c +++ b/kmicromail/libetpan/mime/mailmime_decode.c | |||
@@ -119,104 +119,119 @@ int mailmime_encoded_phrase_parse(const char * default_fromcode, | |||
119 | type = TYPE_ERROR; /* XXX - removes a gcc warning */ | 119 | type = TYPE_ERROR; /* XXX - removes a gcc warning */ |
120 | // LUTZ add | ||
121 | int appendNewLine = FALSE; | ||
122 | while (1) { //while | ||
120 | 123 | ||
121 | while (1) { | 124 | r = mailmime_encoded_word_parse(message, length, &cur_token, &word); |
122 | 125 | if (r == MAILIMF_NO_ERROR) { | |
123 | r = mailmime_encoded_word_parse(message, length, &cur_token, &word); | 126 | if (!first) { |
124 | if (r == MAILIMF_NO_ERROR) { | 127 | if (type != TYPE_ENCODED_WORD) { |
125 | if (!first) { | 128 | if (mmap_string_append_c(gphrase, ' ') == NULL) { |
126 | if (type != TYPE_ENCODED_WORD) { | 129 | mailmime_encoded_word_free(word); |
127 | if (mmap_string_append_c(gphrase, ' ') == NULL) { | 130 | res = MAILIMF_ERROR_MEMORY; |
128 | mailmime_encoded_word_free(word); | 131 | goto free; |
129 | res = MAILIMF_ERROR_MEMORY; | 132 | } |
130 | goto free; | 133 | } |
131 | } | 134 | } |
132 | } | 135 | type = TYPE_ENCODED_WORD; |
133 | } | 136 | wordutf8 = NULL; |
134 | type = TYPE_ENCODED_WORD; | 137 | r = charconv(tocode, word->wd_charset, word->wd_text, |
135 | wordutf8 = NULL; | 138 | strlen(word->wd_text), &wordutf8); |
136 | r = charconv(tocode, word->wd_charset, word->wd_text, | 139 | switch (r) { |
137 | strlen(word->wd_text), &wordutf8); | 140 | case MAIL_CHARCONV_ERROR_MEMORY: |
138 | switch (r) { | 141 | mailmime_encoded_word_free(word); |
139 | case MAIL_CHARCONV_ERROR_MEMORY: | 142 | res = MAILIMF_ERROR_MEMORY; |
140 | mailmime_encoded_word_free(word); | 143 | goto free; |
141 | res = MAILIMF_ERROR_MEMORY; | 144 | |
142 | goto free; | 145 | case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET: |
143 | 146 | case MAIL_CHARCONV_ERROR_CONV: | |
144 | case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET: | 147 | mailmime_encoded_word_free(word); |
145 | case MAIL_CHARCONV_ERROR_CONV: | 148 | res = MAILIMF_ERROR_PARSE; |
146 | mailmime_encoded_word_free(word); | 149 | goto free; |
147 | res = MAILIMF_ERROR_PARSE; | 150 | } |
148 | goto free; | ||
149 | } | ||
150 | 151 | ||
151 | if (wordutf8 != NULL) { | 152 | if (wordutf8 != NULL) { |
152 | if (mmap_string_append(gphrase, wordutf8) == NULL) { | 153 | if (mmap_string_append(gphrase, wordutf8) == NULL) { |
154 | mailmime_encoded_word_free(word); | ||
155 | free(wordutf8); | ||
156 | res = MAILIMF_ERROR_MEMORY; | ||
157 | goto free; | ||
158 | } | ||
159 | free(wordutf8); | ||
160 | } | ||
153 | mailmime_encoded_word_free(word); | 161 | mailmime_encoded_word_free(word); |
154 | free(wordutf8); | 162 | first = FALSE; |
155 | res = MAILIMF_ERROR_MEMORY; | 163 | } |
164 | else if (r == MAILIMF_ERROR_PARSE) { | ||
165 | /* do nothing */ | ||
166 | } | ||
167 | else { | ||
168 | res = r; | ||
156 | goto free; | 169 | goto free; |
157 | } | ||
158 | free(wordutf8); | ||
159 | } | 170 | } |
160 | mailmime_encoded_word_free(word); | ||
161 | first = FALSE; | ||
162 | } | ||
163 | else if (r == MAILIMF_ERROR_PARSE) { | ||
164 | /* do nothing */ | ||
165 | } | ||
166 | else { | ||
167 | res = r; | ||
168 | goto free; | ||
169 | } | ||
170 | |||
171 | if (r == MAILIMF_ERROR_PARSE) { | ||
172 | char * raw_word; | ||
173 | 171 | ||
174 | r = mailmime_non_encoded_word_parse(message, length, | 172 | if (r == MAILIMF_ERROR_PARSE) { |
175 | &cur_token, &raw_word); | 173 | char * raw_word; |
176 | if (r == MAILIMF_NO_ERROR) { | 174 | |
177 | if (!first) { | 175 | r = mailmime_non_encoded_word_parse(message, length, |
178 | if (mmap_string_append_c(gphrase, ' ') == NULL) { | 176 | &cur_token, &raw_word); |
179 | free(raw_word); | 177 | if (r == MAILIMF_NO_ERROR) { |
180 | res = MAILIMF_ERROR_MEMORY; | 178 | if (!first) { |
181 | goto free; | 179 | if (mmap_string_append_c(gphrase, ' ') == NULL) { |
182 | } | 180 | free(raw_word); |
183 | } | 181 | res = MAILIMF_ERROR_MEMORY; |
184 | type = TYPE_WORD; | 182 | goto free; |
183 | } | ||
184 | } | ||
185 | type = TYPE_WORD; | ||
185 | 186 | ||
186 | wordutf8 = NULL; | 187 | wordutf8 = NULL; |
187 | r = charconv(tocode, default_fromcode, raw_word, | 188 | r = charconv(tocode, default_fromcode, raw_word, |
188 | strlen(raw_word), &wordutf8); | 189 | strlen(raw_word), &wordutf8); |
189 | 190 | ||
190 | switch (r) { | 191 | switch (r) { |
191 | case MAIL_CHARCONV_ERROR_MEMORY: | 192 | case MAIL_CHARCONV_ERROR_MEMORY: |
192 | free(raw_word); | 193 | free(raw_word); |
193 | res = MAILIMF_ERROR_MEMORY; | 194 | res = MAILIMF_ERROR_MEMORY; |
194 | goto free; | 195 | goto free; |
195 | 196 | ||
196 | case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET: | 197 | case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET: |
197 | case MAIL_CHARCONV_ERROR_CONV: | 198 | case MAIL_CHARCONV_ERROR_CONV: |
198 | free(raw_word); | 199 | free(raw_word); |
199 | res = MAILIMF_ERROR_PARSE; | 200 | res = MAILIMF_ERROR_PARSE; |
200 | goto free; | 201 | goto free; |
201 | } | 202 | } |
202 | 203 | // LUTZ add | |
203 | if (mmap_string_append(gphrase, wordutf8) == NULL) { | 204 | if ( appendNewLine ) { |
204 | free(wordutf8); | 205 | appendNewLine = FALSE; |
205 | free(raw_word); | 206 | if (mmap_string_append(gphrase, "\n") == NULL) { |
206 | res = MAILIMF_ERROR_MEMORY; | 207 | free(wordutf8); |
207 | goto free; | 208 | free(raw_word); |
208 | } | 209 | res = MAILIMF_ERROR_MEMORY; |
209 | // LUTZ fix | 210 | goto free; |
210 | free(wordutf8); | 211 | } |
211 | free(raw_word); | 212 | } |
212 | first = FALSE; | 213 | //fprintf(stderr,"append *%s* \n",wordutf8 ); |
214 | if (mmap_string_append(gphrase, wordutf8) == NULL) { | ||
215 | free(wordutf8); | ||
216 | free(raw_word); | ||
217 | res = MAILIMF_ERROR_MEMORY; | ||
218 | goto free; | ||
219 | } | ||
220 | // LUTZ fix | ||
221 | free(wordutf8); | ||
222 | free(raw_word); | ||
223 | first = FALSE; | ||
224 | } | ||
225 | else if (r == MAILIMF_ERROR_PARSE) { | ||
226 | // LUTZ add | ||
227 | if ( cur_token >= length ) | ||
228 | break; | ||
229 | ++cur_token; | ||
230 | appendNewLine = TRUE; | ||
231 | } | ||
232 | else { | ||
233 | res = r; | ||
234 | goto free; | ||
235 | } | ||
213 | } | 236 | } |
214 | else if (r == MAILIMF_ERROR_PARSE) { | ||
215 | break; | ||
216 | } | ||
217 | else { | ||
218 | res = r; | ||
219 | goto free; | ||
220 | } | ||
221 | } | ||
222 | } | 237 | } |
@@ -289,4 +304,4 @@ mailmime_non_encoded_word_parse(const char * message, size_t length, | |||
289 | if (cur_token - begin == 0) { | 304 | if (cur_token - begin == 0) { |
290 | res = MAILIMF_ERROR_PARSE; | 305 | res = MAILIMF_ERROR_PARSE; |
291 | goto err; | 306 | goto err; |
292 | } | 307 | } |