summaryrefslogtreecommitdiffabout
path: root/kmicromail/libetpan/imap/mailimap_parser.c
Unidiff
Diffstat (limited to 'kmicromail/libetpan/imap/mailimap_parser.c') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libetpan/imap/mailimap_parser.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/kmicromail/libetpan/imap/mailimap_parser.c b/kmicromail/libetpan/imap/mailimap_parser.c
index 1c2ecde..560e58a 100644
--- a/kmicromail/libetpan/imap/mailimap_parser.c
+++ b/kmicromail/libetpan/imap/mailimap_parser.c
@@ -2378,50 +2378,68 @@ mailimap_body_fld_enc_parse(mailstream * fd, MMAPString * buffer,
2378 struct mailimap_body_fld_enc ** result, 2378 struct mailimap_body_fld_enc ** result,
2379 size_t progr_rate, 2379 size_t progr_rate,
2380 progress_function * progr_fun) 2380 progress_function * progr_fun)
2381{ 2381{
2382 size_t cur_token; 2382 size_t cur_token;
2383 int type; 2383 int type;
2384 char * value; 2384 char * value;
2385 struct mailimap_body_fld_enc * body_fld_enc; 2385 struct mailimap_body_fld_enc * body_fld_enc;
2386 int r; 2386 int r;
2387 int res; 2387 int res;
2388 2388
2389 cur_token = * index; 2389 cur_token = * index;
2390 2390
2391 r = mailimap_body_fld_known_enc_parse(fd, buffer, &cur_token, 2391 r = mailimap_body_fld_known_enc_parse(fd, buffer, &cur_token,
2392 &type, progr_rate, progr_fun); 2392 &type, progr_rate, progr_fun);
2393 if (r == MAILIMAP_NO_ERROR) { 2393 if (r == MAILIMAP_NO_ERROR) {
2394 value = NULL; 2394 value = NULL;
2395 } 2395 }
2396 else if (r == MAILIMAP_ERROR_PARSE) { 2396 else if (r == MAILIMAP_ERROR_PARSE) {
2397 type = MAILIMAP_BODY_FLD_ENC_OTHER; 2397 type = MAILIMAP_BODY_FLD_ENC_OTHER;
2398 2398
2399 r = mailimap_string_parse(fd, buffer, &cur_token, &value, NULL, 2399 r = mailimap_string_parse(fd, buffer, &cur_token, &value, NULL,
2400 progr_rate, progr_fun); 2400 progr_rate, progr_fun);
2401 if (r != MAILIMAP_NO_ERROR) { 2401 if (r != MAILIMAP_NO_ERROR) {
2402 res = r; 2402 // LR start
2403 goto err; 2403 // accept NIL and set type to utf8
2404 int ret = r;
2405 r = mailimap_char_parse(fd, buffer, &cur_token, 'N');
2406 if (r == MAILIMAP_NO_ERROR) {
2407 r = mailimap_char_parse(fd, buffer, &cur_token, 'I');
2408 if (r == MAILIMAP_NO_ERROR) {
2409 r = mailimap_char_parse(fd, buffer, &cur_token, 'L');
2410 if (r == MAILIMAP_NO_ERROR) {
2411 type = 4;
2412 ret = MAILIMAP_NO_ERROR;
2413 value = NULL;
2414 }
2415 }
2416 }
2417 if ( ret != MAILIMAP_NO_ERROR ) {
2418 res = ret;
2419 goto err;
2420 }
2421 // LR end
2404 } 2422 }
2405 } 2423 }
2406 else { 2424 else {
2407 res = r; 2425 res = r;
2408 goto err; 2426 goto err;
2409 } 2427 }
2410 2428
2411 body_fld_enc = mailimap_body_fld_enc_new(type, value); 2429 body_fld_enc = mailimap_body_fld_enc_new(type, value);
2412 if (body_fld_enc == NULL) { 2430 if (body_fld_enc == NULL) {
2413 res = MAILIMAP_ERROR_MEMORY; 2431 res = MAILIMAP_ERROR_MEMORY;
2414 goto value_free; 2432 goto value_free;
2415 } 2433 }
2416 2434
2417 * result = body_fld_enc; 2435 * result = body_fld_enc;
2418 * index = cur_token; 2436 * index = cur_token;
2419 2437
2420 return MAILIMAP_NO_ERROR; 2438 return MAILIMAP_NO_ERROR;
2421 2439
2422 value_free: 2440 value_free:
2423 if (value) 2441 if (value)
2424 mailimap_string_free(value); 2442 mailimap_string_free(value);
2425 err: 2443 err:
2426 return res; 2444 return res;
2427} 2445}