summaryrefslogtreecommitdiffabout
path: root/kmicromail/libetpan
authorzautrix <zautrix>2004-11-06 23:30:02 (UTC)
committer zautrix <zautrix>2004-11-06 23:30:02 (UTC)
commit023e0e82dd8bf6421d12492a2dd25534fc43ad31 (patch) (side-by-side diff)
treecf0533e3ccc642cb57a41953f184f457fa5365ba /kmicromail/libetpan
parentf8841c92d5251f713eb7a025af8fdee52de45b3d (diff)
downloadkdepimpi-023e0e82dd8bf6421d12492a2dd25534fc43ad31.zip
kdepimpi-023e0e82dd8bf6421d12492a2dd25534fc43ad31.tar.gz
kdepimpi-023e0e82dd8bf6421d12492a2dd25534fc43ad31.tar.bz2
many ompi fixes
Diffstat (limited to 'kmicromail/libetpan') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libetpan/mime/mailmime_decode.c203
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
@@ -117,108 +117,123 @@ int mailmime_encoded_phrase_parse(const char * default_fromcode,
first = TRUE;
type = TYPE_ERROR; /* XXX - removes a gcc warning */
+ // LUTZ add
+ int appendNewLine = FALSE;
+ while (1) { //while
- while (1) {
-
- r = mailmime_encoded_word_parse(message, length, &cur_token, &word);
- if (r == MAILIMF_NO_ERROR) {
- if (!first) {
- if (type != TYPE_ENCODED_WORD) {
- if (mmap_string_append_c(gphrase, ' ') == NULL) {
- mailmime_encoded_word_free(word);
- res = MAILIMF_ERROR_MEMORY;
- goto free;
- }
- }
- }
- type = TYPE_ENCODED_WORD;
- wordutf8 = NULL;
- r = charconv(tocode, word->wd_charset, word->wd_text,
- strlen(word->wd_text), &wordutf8);
- switch (r) {
- case MAIL_CHARCONV_ERROR_MEMORY:
- mailmime_encoded_word_free(word);
- res = MAILIMF_ERROR_MEMORY;
- goto free;
-
- case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET:
- case MAIL_CHARCONV_ERROR_CONV:
- mailmime_encoded_word_free(word);
- res = MAILIMF_ERROR_PARSE;
- goto free;
- }
+ r = mailmime_encoded_word_parse(message, length, &cur_token, &word);
+ if (r == MAILIMF_NO_ERROR) {
+ if (!first) {
+ if (type != TYPE_ENCODED_WORD) {
+ if (mmap_string_append_c(gphrase, ' ') == NULL) {
+ mailmime_encoded_word_free(word);
+ res = MAILIMF_ERROR_MEMORY;
+ goto free;
+ }
+ }
+ }
+ type = TYPE_ENCODED_WORD;
+ wordutf8 = NULL;
+ r = charconv(tocode, word->wd_charset, word->wd_text,
+ strlen(word->wd_text), &wordutf8);
+ switch (r) {
+ case MAIL_CHARCONV_ERROR_MEMORY:
+ mailmime_encoded_word_free(word);
+ res = MAILIMF_ERROR_MEMORY;
+ goto free;
+
+ case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET:
+ case MAIL_CHARCONV_ERROR_CONV:
+ mailmime_encoded_word_free(word);
+ res = MAILIMF_ERROR_PARSE;
+ goto free;
+ }
- if (wordutf8 != NULL) {
- if (mmap_string_append(gphrase, wordutf8) == NULL) {
+ if (wordutf8 != NULL) {
+ if (mmap_string_append(gphrase, wordutf8) == NULL) {
+ mailmime_encoded_word_free(word);
+ free(wordutf8);
+ res = MAILIMF_ERROR_MEMORY;
+ goto free;
+ }
+ free(wordutf8);
+ }
mailmime_encoded_word_free(word);
- free(wordutf8);
- res = MAILIMF_ERROR_MEMORY;
+ first = FALSE;
+ }
+ else if (r == MAILIMF_ERROR_PARSE) {
+ /* do nothing */
+ }
+ else {
+ res = r;
goto free;
- }
- free(wordutf8);
}
- mailmime_encoded_word_free(word);
- first = FALSE;
- }
- else if (r == MAILIMF_ERROR_PARSE) {
- /* do nothing */
- }
- else {
- res = r;
- goto free;
- }
-
- if (r == MAILIMF_ERROR_PARSE) {
- char * raw_word;
- r = mailmime_non_encoded_word_parse(message, length,
- &cur_token, &raw_word);
- if (r == MAILIMF_NO_ERROR) {
- if (!first) {
- if (mmap_string_append_c(gphrase, ' ') == NULL) {
- free(raw_word);
- res = MAILIMF_ERROR_MEMORY;
- goto free;
- }
- }
- type = TYPE_WORD;
+ if (r == MAILIMF_ERROR_PARSE) {
+ char * raw_word;
+
+ r = mailmime_non_encoded_word_parse(message, length,
+ &cur_token, &raw_word);
+ if (r == MAILIMF_NO_ERROR) {
+ if (!first) {
+ if (mmap_string_append_c(gphrase, ' ') == NULL) {
+ free(raw_word);
+ res = MAILIMF_ERROR_MEMORY;
+ goto free;
+ }
+ }
+ type = TYPE_WORD;
- wordutf8 = NULL;
- r = charconv(tocode, default_fromcode, raw_word,
- strlen(raw_word), &wordutf8);
+ wordutf8 = NULL;
+ r = charconv(tocode, default_fromcode, raw_word,
+ strlen(raw_word), &wordutf8);
- switch (r) {
- case MAIL_CHARCONV_ERROR_MEMORY:
- free(raw_word);
- res = MAILIMF_ERROR_MEMORY;
- goto free;
+ switch (r) {
+ case MAIL_CHARCONV_ERROR_MEMORY:
+ free(raw_word);
+ res = MAILIMF_ERROR_MEMORY;
+ goto free;
- case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET:
- case MAIL_CHARCONV_ERROR_CONV:
- free(raw_word);
- res = MAILIMF_ERROR_PARSE;
- goto free;
- }
-
- if (mmap_string_append(gphrase, wordutf8) == NULL) {
- free(wordutf8);
- free(raw_word);
- res = MAILIMF_ERROR_MEMORY;
- goto free;
- }
- // LUTZ fix
- free(wordutf8);
- free(raw_word);
- first = FALSE;
+ case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET:
+ case MAIL_CHARCONV_ERROR_CONV:
+ free(raw_word);
+ res = MAILIMF_ERROR_PARSE;
+ goto free;
+ }
+ // LUTZ add
+ if ( appendNewLine ) {
+ appendNewLine = FALSE;
+ if (mmap_string_append(gphrase, "\n") == NULL) {
+ free(wordutf8);
+ free(raw_word);
+ res = MAILIMF_ERROR_MEMORY;
+ goto free;
+ }
+ }
+ //fprintf(stderr,"append *%s* \n",wordutf8 );
+ if (mmap_string_append(gphrase, wordutf8) == NULL) {
+ free(wordutf8);
+ free(raw_word);
+ res = MAILIMF_ERROR_MEMORY;
+ goto free;
+ }
+ // LUTZ fix
+ free(wordutf8);
+ free(raw_word);
+ first = FALSE;
+ }
+ else if (r == MAILIMF_ERROR_PARSE) {
+ // LUTZ add
+ if ( cur_token >= length )
+ break;
+ ++cur_token;
+ appendNewLine = TRUE;
+ }
+ else {
+ res = r;
+ goto free;
+ }
}
- else if (r == MAILIMF_ERROR_PARSE) {
- break;
- }
- else {
- res = r;
- goto free;
- }
- }
}
if (first) {
@@ -287,8 +302,8 @@ mailmime_non_encoded_word_parse(const char * message, size_t length,
}
if (cur_token - begin == 0) {
- res = MAILIMF_ERROR_PARSE;
- goto err;
+ res = MAILIMF_ERROR_PARSE;
+ goto err;
}
text = malloc(cur_token - begin + 1);