# HG changeset patch # User Timo Sirainen # Date 1241454779 14400 # Node ID 05a98aaf0aaf00031a4146a8b0cd019247c4ddb7 # Parent e569d73e905601959867e2c94c6583a76bdf8072 Try to skip over errors in Content-Type parameters. diff -r e569d73e9056 -r 05a98aaf0aaf src/lib-mail/rfc2231-parser.c --- a/src/lib-mail/rfc2231-parser.c Sun May 03 22:04:39 2009 -0400 +++ b/src/lib-mail/rfc2231-parser.c Mon May 04 12:32:59 2009 -0400 @@ -46,7 +46,7 @@ const char *key, *value, *p, *p2; string_t *str; unsigned int i, j, count, next, next_idx; - bool ok, have_extended; + bool ok, have_extended, broken = FALSE; int ret; /* Get a list of all parameters. RFC 2231 uses key*[*]=value pairs, @@ -55,7 +55,15 @@ memset(&rfc2231_param, 0, sizeof(rfc2231_param)); t_array_init(&result, 8); t_array_init(&rfc2231_params_arr, 8); - while ((ret = rfc822_parse_content_param(ctx, &key, &value)) > 0) { + while ((ret = rfc822_parse_content_param(ctx, &key, &value)) != 0) { + if (ret < 0) { + /* try to continue anyway.. */ + broken = TRUE; + if (ctx->data == ctx->end) + break; + ctx->data++; + continue; + } p = strchr(key, '*'); if (p != NULL) { p2 = p++; @@ -89,7 +97,7 @@ /* No RFC 2231 parameters */ (void)array_append_space(&result); /* NULL-terminate */ *result_r = array_idx(&result, 0); - return ret; + return broken ? -1 : 0; } /* Merge the RFC 2231 parameters. Since their order isn't guaranteed to @@ -157,5 +165,5 @@ } (void)array_append_space(&result); /* NULL-terminate */ *result_r = array_idx(&result, 0); - return ret; + return broken ? -1 : 0; }