Commit e2e6fa5e e2e6fa5e54eb3a365aa968ec4e3c83ff55d9be85 by Sergey Poznyakoff

(_mime_parse_mpart_message): The CRLF preceding the encapsulation line is concep…

…tually attached to the boundary.
1 parent 6ace2b21
...@@ -325,8 +325,6 @@ _mime_parse_mpart_message (mu_mime_t mime) ...@@ -325,8 +325,6 @@ _mime_parse_mpart_message (mu_mime_t mime)
325 cp2 = 325 cp2 =
326 mime->cur_line[0] == 326 mime->cur_line[0] ==
327 '\n' ? mime->cur_line + 1 : mime->cur_line; 327 '\n' ? mime->cur_line + 1 : mime->cur_line;
328 if (mime->header_length)
329 mb_lines++;
330 if (mime->line_ndx >= blength) 328 if (mime->line_ndx >= blength)
331 { 329 {
332 if ((!strncasecmp (cp2, "--", 2) 330 if ((!strncasecmp (cp2, "--", 2)
...@@ -338,10 +336,19 @@ _mime_parse_mpart_message (mu_mime_t mime) ...@@ -338,10 +336,19 @@ _mime_parse_mpart_message (mu_mime_t mime)
338 mime->flags &= ~MIME_PARSER_HAVE_CR; 336 mime->flags &= ~MIME_PARSER_HAVE_CR;
339 mb_length = mime->cur_offset - 337 mb_length = mime->cur_offset -
340 mb_offset - mime->line_ndx; 338 mb_offset - mime->line_ndx;
341 if (mb_lines > 1)
342 mb_length++;
343 if (mime->header_length) 339 if (mime->header_length)
344 /* this skips the preamble */ 340 /* this skips the preamble */
341 /* RFC 1521 [Page 30]:
342 NOTE: The CRLF preceding the encapsulation line
343 is conceptually attached to the boundary so
344 that it is possible to have a part that does
345 not end with a CRLF (line break). Body parts
346 that must be considered to end with line
347 breaks, therefore, must have two CRLFs
348 preceding the encapsulation line, the first
349 of which is part of the preceding body part,
350 and the second of which is part of the
351 encapsulation boundary. */
345 _mime_append_part (mime, NULL, 352 _mime_append_part (mime, NULL,
346 mb_offset, mb_length, 353 mb_offset, mb_length,
347 mb_lines - 1); 354 mb_lines - 1);
...@@ -360,6 +367,9 @@ _mime_parse_mpart_message (mu_mime_t mime) ...@@ -360,6 +367,9 @@ _mime_parse_mpart_message (mu_mime_t mime)
360 break; 367 break;
361 } 368 }
362 } 369 }
370 else if (mime->header_length)
371 mb_lines++;
372
363 mime->line_ndx = 0; 373 mime->line_ndx = 0;
364 mime->cur_line[0] = *cp; /* stay in this state but 374 mime->cur_line[0] = *cp; /* stay in this state but
365 leave '\n' at begining */ 375 leave '\n' at begining */
......