dovecot-2.0-sslstream: rfc2231 parser: Fixed parsing "key*".
dovecot at dovecot.org
dovecot at dovecot.org
Sat Feb 13 02:56:21 EET 2010
details: http://hg.dovecot.org/dovecot-2.0-sslstream/rev/037299bb2199
changeset: 10314:037299bb2199
user: Timo Sirainen <tss at iki.fi>
date: Thu Nov 12 12:42:31 2009 -0500
description:
rfc2231 parser: Fixed parsing "key*".
diffstat:
2 files changed, 17 insertions(+), 18 deletions(-)
src/lib-mail/rfc2231-parser.c | 13 ++++++++-----
src/lib-mail/test-rfc2231-parser.c | 22 +++++++++-------------
diffs (69 lines):
diff -r 3baf1cb9fdda -r 037299bb2199 src/lib-mail/rfc2231-parser.c
--- a/src/lib-mail/rfc2231-parser.c Wed Nov 11 15:40:18 2009 -0500
+++ b/src/lib-mail/rfc2231-parser.c Thu Nov 12 12:42:31 2009 -0500
@@ -67,11 +67,14 @@ int rfc2231_parse(struct rfc822_parser_c
}
p = strchr(key, '*');
if (p != NULL) {
- p2 = p++;
- rfc2231_param.idx = 0;
- for (; *p >= '0' && *p <= '9'; p++) {
- rfc2231_param.idx =
- rfc2231_param.idx*10 + *p - '0';
+ p2 = p;
+ if (p[1] != '\0') {
+ p++;
+ rfc2231_param.idx = 0;
+ for (; *p >= '0' && *p <= '9'; p++) {
+ rfc2231_param.idx =
+ rfc2231_param.idx*10 + *p - '0';
+ }
}
if (*p != '*')
rfc2231_param.extended = FALSE;
diff -r 3baf1cb9fdda -r 037299bb2199 src/lib-mail/test-rfc2231-parser.c
--- a/src/lib-mail/test-rfc2231-parser.c Wed Nov 11 15:40:18 2009 -0500
+++ b/src/lib-mail/test-rfc2231-parser.c Thu Nov 12 12:42:31 2009 -0500
@@ -8,6 +8,7 @@ static void test_rfc2231_parser(void)
static void test_rfc2231_parser(void)
{
const char *input =
+ "; key4*=us-ascii''foo"
"; key*2=ba%"
"; key2*0=a"
"; key3*0*=us-ascii'en'xyz"
@@ -22,26 +23,21 @@ static void test_rfc2231_parser(void)
"''ab%25",
"key3*",
"us-ascii'en'xyzplop%25",
+ "key4*",
+ "us-ascii''foo",
NULL
};
struct rfc822_parser_context parser;
const char *const *result;
unsigned int i;
- bool success;
+ test_begin("rfc2231 parser");
rfc822_parser_init(&parser, (const void *)input, strlen(input), NULL);
- if (rfc2231_parse(&parser, &result) < 0)
- success = FALSE;
- else {
- success = TRUE;
- for (i = 0; output[i] != NULL && result[i] != NULL; i++) {
- if (strcmp(output[i], result[i]) != 0)
- break;
- }
- if (output[i] != NULL || result[i] != NULL)
- success = FALSE;
- }
- test_out("rfc2231_parse()", success);
+ test_assert(rfc2231_parse(&parser, &result) == 0);
+ for (i = 0; output[i] != NULL && result[i] != NULL; i++)
+ test_assert(strcmp(output[i], result[i]) == 0);
+ test_assert(output[i] == NULL && result[i] == NULL);
+ test_end();
}
int main(void)
More information about the dovecot-cvs
mailing list