From: DINH V. Ho? <ho...@us...> - 2002-07-26 09:14:35
|
Update of /cvsroot/libetpan/libetpan/mbox In directory usw-pr-cvs1:/tmp/cvs-serv9123 Modified Files: mailmbox_parse.c Log Message: bugfix in mbox parsing when body is null Index: mailmbox_parse.c =================================================================== RCS file: /cvsroot/libetpan/libetpan/mbox/mailmbox_parse.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- mailmbox_parse.c 14 Jul 2002 14:13:15 -0000 1.4 +++ mailmbox_parse.c 26 Jul 2002 09:14:32 -0000 1.5 @@ -145,7 +145,9 @@ size_t message_length; uint32_t uid; int r; +#if 0 size_t begin; +#endif int state; @@ -162,14 +164,14 @@ if (strncmp(str + cur_token, "From ", 5) == 0) { cur_token += 5; while (str[cur_token] != '\n') { - cur_token ++; - if (cur_token >= length) - break; + cur_token ++; + if (cur_token >= length) + break; } if (cur_token < length) { - cur_token ++; - headers = cur_token; - start_len = headers - start; + cur_token ++; + headers = cur_token; + start_len = headers - start; } } } @@ -182,14 +184,24 @@ return r; /* save position */ +#if 0 begin = cur_token; - +#endif + mailimf_crlf_parse(str, length, &cur_token); +#if 0 + if (str[cur_token] == 'F') { + printf("start !\n"); + printf("%50.50s\n", str + cur_token); + getchar(); + } +#endif + body = cur_token; /* restore position */ - cur_token = begin; + /* cur_token = begin; */ state = IN_MAIL; @@ -198,6 +210,7 @@ while (state != OUT_MAIL) { if (cur_token >= length) { + end = length; next = length; break; } @@ -206,11 +219,16 @@ case IN_MAIL: switch(str[cur_token]) { case '\r': - state = FIRST_CR; - break; + state = FIRST_CR; + break; case '\n': - state = FIRST_LF; - break; + state = FIRST_LF; + break; + case 'F': + end = cur_token; + next = cur_token; + state = PARSING_F; + break; } break; @@ -218,113 +236,113 @@ end = cur_token; switch(str[cur_token]) { case '\r': - state = SECOND_CR; - break; + state = SECOND_CR; + break; case '\n': - state = FIRST_LF; - break; + state = FIRST_LF; + break; default: - state = IN_MAIL; - break; + state = IN_MAIL; + break; } break; - + case FIRST_LF: end = cur_token; switch(str[cur_token]) { case '\r': - state = SECOND_CR; - break; + state = SECOND_CR; + break; case '\n': - state = SECOND_LF; - break; + state = SECOND_LF; + break; default: - state = IN_MAIL; - break; + state = IN_MAIL; + break; } break; - + case SECOND_CR: switch(str[cur_token]) { - case '\r': - end = cur_token; - break; - case '\n': - state = SECOND_LF; - break; - case 'F': - next = cur_token; - state = PARSING_F; - break; - default: - state = IN_MAIL; - break; + case '\r': + end = cur_token; + break; + case '\n': + state = SECOND_LF; + break; + case 'F': + next = cur_token; + state = PARSING_F; + break; + default: + state = IN_MAIL; + break; } break; case SECOND_LF: switch(str[cur_token]) { - case '\r': - state = SECOND_CR; - break; - case '\n': - end = cur_token; - break; - case 'F': - next = cur_token; - state = PARSING_F; - break; - default: - state = IN_MAIL; - break; + case '\r': + state = SECOND_CR; + break; + case '\n': + end = cur_token; + break; + case 'F': + next = cur_token; + state = PARSING_F; + break; + default: + state = IN_MAIL; + break; } break; - + case PARSING_F: switch(str[cur_token]) { - case 'r': - state = PARSING_R; - break; - default: - state = IN_MAIL; - break; + case 'r': + state = PARSING_R; + break; + default: + state = IN_MAIL; + break; } break; - + case PARSING_R: switch(str[cur_token]) { - case 'o': - state = PARSING_O; - break; - default: - state = IN_MAIL; - break; + case 'o': + state = PARSING_O; + break; + default: + state = IN_MAIL; + break; } break; - + case PARSING_O: switch(str[cur_token]) { - case 'm': - state = PARSING_M; - break; - default: - state = IN_MAIL; - break; + case 'm': + state = PARSING_M; + break; + default: + state = IN_MAIL; + break; } break; case PARSING_M: switch(str[cur_token]) { - case ' ': - state = OUT_MAIL; - break; + case ' ': + state = OUT_MAIL; + break; default: - state = IN_MAIL; - break; + state = IN_MAIL; + break; } break; } - + cur_token ++; } |