Fix a bug in imap4d parser, add more tests.
* imap4d/io.c (gettok): Fix memory overwrite. * imap4d/tests/fetch.at: Add checks for HEADER, HEADER.FIELDS, HEADER.FIELDS.NOT, and TEXT applied to message/rfc822 parts. * testsuite/spool/msg.mbox: New file. * testsuite/spool/DISTFILES: Add msg.mbox.
Showing
4 changed files
with
94 additions
and
11 deletions
... | @@ -528,9 +528,9 @@ gettok (struct imap4d_tokbuf *tok, size_t off) | ... | @@ -528,9 +528,9 @@ gettok (struct imap4d_tokbuf *tok, size_t off) |
528 | return insert_nul (tok, off); | 528 | return insert_nul (tok, off); |
529 | off++; | 529 | off++; |
530 | } | 530 | } |
531 | buf[off++] = 0; | 531 | insert_nul (tok, off); |
532 | 532 | ||
533 | return off; | 533 | return off + 1; |
534 | } | 534 | } |
535 | 535 | ||
536 | static void | 536 | static void | ... | ... |
... | @@ -14,7 +14,8 @@ | ... | @@ -14,7 +14,8 @@ |
14 | # You should have received a copy of the GNU General Public License | 14 | # You should have received a copy of the GNU General Public License |
15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | 15 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | ||
17 | dnl FETCH_CHECK([NAME=`'],[KW=`'],[ARG=`'],[OUTPUT=`'],[MBOX=mbox1],[FILTERS=`']) | 17 | dnl FETCH_CHECK([NAME=`'],[KW=`'],[ARG=`'],[OUTPUT=`'],[MBOX=mbox1], |
18 | dnl [FILTERS=`']) | ||
18 | m4_define([FETCH_CHECK],[ | 19 | m4_define([FETCH_CHECK],[ |
19 | AT_SETUP([$1]) | 20 | AT_SETUP([$1]) |
20 | AT_KEYWORDS([fetch $2]) | 21 | AT_KEYWORDS([fetch $2]) |
... | @@ -324,10 +325,48 @@ bGFyIHN0cmVuZ3RoLCB3aGljaCBpdCBnYXZlIHRvIG15IGphdywKSGFzIGxhc3RlZCB0aGUgcmVz | ... | @@ -324,10 +325,48 @@ bGFyIHN0cmVuZ3RoLCB3aGljaCBpdCBnYXZlIHRvIG15IGphdywKSGFzIGxhc3RlZCB0aGUgcmVz |
324 | dCBvZiBteSBsaWZlLicK | 325 | dCBvZiBteSBsaWZlLicK |
325 | )]) | 326 | )]) |
326 | 327 | ||
328 | # The HEADER, HEADER.FIELDS, HEADER.FIELDS.NOT, and TEXT part | ||
329 | # specifiers can be the sole part specifier or can be prefixed by | ||
330 | # one or more numeric part specifiers, provided that the numeric | ||
331 | # part specifier refers to a part of type MESSAGE/RFC822. The | ||
332 | # MIME part specifier MUST be prefixed by one or more numeric | ||
333 | # part specifiers. | ||
334 | |||
335 | FETCH_CHECK([N.HEADER (text/plain)],[fetch-header-subpart-text fetch18], | ||
336 | [1 BODY[[1.HEADER]]], | ||
337 | [* 1 FETCH (BODY[[1.HEADER]] NIL)], | ||
338 | [msg.mbox]) | ||
339 | |||
340 | FETCH_CHECK([N.HEADER (message/rfc822)],[fetch-header-subpart-msg fetch19], | ||
341 | [1 BODY[[2.HEADER]]], | ||
342 | [* 1 FETCH (BODY[[2.HEADER]] {406} | ||
343 | Message-ID: <20111123103317.27412@host.example.org> | ||
344 | Date: Wed, 23 Nov 2011 10:33:17 +0200 | ||
345 | From: Sergey Poznyakoff <gray@example.org> | ||
346 | To: <gray@example.com> | ||
347 | Subject: Re: RFC822 Subtype | ||
348 | In-reply-to: Your message of Wed, 23 Nov 2011 08:48:16 +0100 | ||
349 | <87wrar6zzz@example.com> | ||
350 | References: <87wrar6zzz@example.com> | ||
351 | X-Envelope-Date: Wed Nov 23 08:33:17 2011 | ||
352 | X-Envelope-Sender: gray@example.org | ||
353 | |||
354 | )], | ||
355 | [msg.mbox]) | ||
356 | |||
357 | FETCH_CHECK([N.HEADER.FIELDS],[fetch-header-fields-subpart fetch20], | ||
358 | [1 BODY[[2.HEADER.FIELDS (FROM TO)]]], | ||
359 | [* 1 FETCH (BODY[[2.HEADER.FIELDS (FROM TO)]] {70} | ||
360 | FROM: Sergey Poznyakoff <gray@example.org> | ||
361 | TO: <gray@example.com> | ||
362 | |||
363 | )], | ||
364 | [msg.mbox]) | ||
365 | |||
327 | # BODY.PEEK[<section>]<<partial>> | 366 | # BODY.PEEK[<section>]<<partial>> |
328 | # An alternate form of BODY[<section>] that does not | 367 | # An alternate form of BODY[<section>] that does not |
329 | # implicitly set the \Seen flag. | 368 | # implicitly set the \Seen flag. |
330 | FETCH_CHECK([BODY.PEEK[[HEADER]]],[fetch-body-peek-header fetch18], | 369 | FETCH_CHECK([BODY.PEEK[[HEADER]]],[fetch-body-peek-header fetch21], |
331 | [1 BODY.PEEK[[HEADER]]], | 370 | [1 BODY.PEEK[[HEADER]]], |
332 | [* 1 FETCH (BODY[[HEADER]] {326} | 371 | [* 1 FETCH (BODY[[HEADER]] {326} |
333 | Received: (from foobar@nonexistent.net) | 372 | Received: (from foobar@nonexistent.net) |
... | @@ -345,7 +384,7 @@ Subject: Jabberwocky | ... | @@ -345,7 +384,7 @@ Subject: Jabberwocky |
345 | # syntax of the resulting untagged FETCH data (RFC822 | 384 | # syntax of the resulting untagged FETCH data (RFC822 |
346 | # is returned). | 385 | # is returned). |
347 | 386 | ||
348 | FETCH_CHECK([RFC822],[fetch-rfc822 fetch19], | 387 | FETCH_CHECK([RFC822],[fetch-rfc822 fetch22], |
349 | [1 RFC822], | 388 | [1 RFC822], |
350 | [* 1 FETCH (FLAGS (\Seen) RFC822 {1298} | 389 | [* 1 FETCH (FLAGS (\Seen) RFC822 {1298} |
351 | Received: (from foobar@nonexistent.net) | 390 | Received: (from foobar@nonexistent.net) |
... | @@ -398,7 +437,7 @@ And the mome raths outgrabe. | ... | @@ -398,7 +437,7 @@ And the mome raths outgrabe. |
398 | # differing in the syntax of the resulting untagged | 437 | # differing in the syntax of the resulting untagged |
399 | # FETCH data (RFC822.HEADER is returned). | 438 | # FETCH data (RFC822.HEADER is returned). |
400 | # FIXME: Should it set \Seen flag? | 439 | # FIXME: Should it set \Seen flag? |
401 | FETCH_CHECK([RFC822.HEADER],[fetch-rfc822-header fetch20], | 440 | FETCH_CHECK([RFC822.HEADER],[fetch-rfc822-header fetch23], |
402 | [2 RFC822.HEADER], | 441 | [2 RFC822.HEADER], |
403 | [* 2 FETCH (RFC822.HEADER {328} | 442 | [* 2 FETCH (RFC822.HEADER {328} |
404 | Received: (from bar@dontmailme.org) | 443 | Received: (from bar@dontmailme.org) |
... | @@ -414,14 +453,14 @@ Subject: Re: Jabberwocky | ... | @@ -414,14 +453,14 @@ Subject: Re: Jabberwocky |
414 | 453 | ||
415 | # RFC822.SIZE The [RFC-822] size of the message. | 454 | # RFC822.SIZE The [RFC-822] size of the message. |
416 | 455 | ||
417 | FETCH_CHECK([RFC822.SIZE],[fetch-rfc822-size fetch21], | 456 | FETCH_CHECK([RFC822.SIZE],[fetch-rfc822-size fetch24], |
418 | [3 RFC822.SIZE], | 457 | [3 RFC822.SIZE], |
419 | [* 3 FETCH (RFC822.SIZE 1611)]) | 458 | [* 3 FETCH (RFC822.SIZE 1611)]) |
420 | 459 | ||
421 | # RFC822.TEXT Functionally equivalent to BODY[TEXT], differing in | 460 | # RFC822.TEXT Functionally equivalent to BODY[TEXT], differing in |
422 | # the syntax of the resulting untagged FETCH data | 461 | # the syntax of the resulting untagged FETCH data |
423 | # (RFC822.TEXT is returned). | 462 | # (RFC822.TEXT is returned). |
424 | FETCH_CHECK([RFC822.TEXT],[fetch-rfc822-text fetch22], | 463 | FETCH_CHECK([RFC822.TEXT],[fetch-rfc822-text fetch25], |
425 | [2 RFC822.TEXT], | 464 | [2 RFC822.TEXT], |
426 | [* 2 FETCH (FLAGS (\Seen) RFC822.TEXT {219} | 465 | [* 2 FETCH (FLAGS (\Seen) RFC822.TEXT {219} |
427 | It seems very pretty, but it's *rather* hard to understand!' | 466 | It seems very pretty, but it's *rather* hard to understand!' |
... | @@ -433,7 +472,7 @@ that's clear, at any rate... | ... | @@ -433,7 +472,7 @@ that's clear, at any rate... |
433 | # FAST Macro equivalent to: (FLAGS INTERNALDATE | 472 | # FAST Macro equivalent to: (FLAGS INTERNALDATE |
434 | # RFC822.SIZE) | 473 | # RFC822.SIZE) |
435 | 474 | ||
436 | FETCH_CHECK([FAST],[fetch-fast fetch23], | 475 | FETCH_CHECK([FAST],[fetch-fast fetch26], |
437 | [1 FAST], | 476 | [1 FAST], |
438 | [* 1 FETCH (FLAGS (\Recent) INTERNALDATE "28-Dec-2001 22:18:09 +0000" RFC822.SIZE 1298)], | 477 | [* 1 FETCH (FLAGS (\Recent) INTERNALDATE "28-Dec-2001 22:18:09 +0000" RFC822.SIZE 1298)], |
439 | [], | 478 | [], |
... | @@ -442,11 +481,10 @@ FETCH_CHECK([FAST],[fetch-fast fetch23], | ... | @@ -442,11 +481,10 @@ FETCH_CHECK([FAST],[fetch-fast fetch23], |
442 | # FULL Macro equivalent to: (FLAGS INTERNALDATE | 481 | # FULL Macro equivalent to: (FLAGS INTERNALDATE |
443 | # RFC822.SIZE ENVELOPE BODY) | 482 | # RFC822.SIZE ENVELOPE BODY) |
444 | 483 | ||
445 | FETCH_CHECK([FULL],[fetch-full fetch24], | 484 | FETCH_CHECK([FULL],[fetch-full fetch27], |
446 | [4 FULL], | 485 | [4 FULL], |
447 | [* 4 FETCH (FLAGS (\Recent) INTERNALDATE "13-Jul-2002 00:50:58 +0000" RFC822.SIZE 3483 ENVELOPE ("Sat, 13 Jul 2002 00:50:58 +0300" "Nested MIME" (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) NIL NIL NIL "<200207122150.g6CLowb05126@example.net>") BODY (("text" "plain" ("name" "msg.21" "charset" "us-ascii") "<5122.1026510654.2@example.net>" "Father William Part I" "7BIT" 351 10)(("application" "octet-stream" ("name" "msg.22") "<5122.1026510654.4@example.net>" "Father William Part II" "base64" 486)(("application" "octet-stream" ("name" "msg.23") "<5122.1026510654.6@example.net>" "Father William Part III" "base64" 490)("application" "octet-stream" ("name" "msg.24") "<5122.1026510654.7@example.net>" "Father William Part IV" "base64" 502) "mixed" NIL NIL NIL) "mixed" NIL NIL NIL) "mixed" NIL NIL NIL))], | 486 | [* 4 FETCH (FLAGS (\Recent) INTERNALDATE "13-Jul-2002 00:50:58 +0000" RFC822.SIZE 3483 ENVELOPE ("Sat, 13 Jul 2002 00:50:58 +0300" "Nested MIME" (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Sergey Poznyakoff" NIL "gray" "example.net")) (("Foo Bar" NIL "foobar" "nonexistent.net")) NIL NIL NIL "<200207122150.g6CLowb05126@example.net>") BODY (("text" "plain" ("name" "msg.21" "charset" "us-ascii") "<5122.1026510654.2@example.net>" "Father William Part I" "7BIT" 351 10)(("application" "octet-stream" ("name" "msg.22") "<5122.1026510654.4@example.net>" "Father William Part II" "base64" 486)(("application" "octet-stream" ("name" "msg.23") "<5122.1026510654.6@example.net>" "Father William Part III" "base64" 490)("application" "octet-stream" ("name" "msg.24") "<5122.1026510654.7@example.net>" "Father William Part IV" "base64" 502) "mixed" NIL NIL NIL) "mixed" NIL NIL NIL) "mixed" NIL NIL NIL))], |
448 | [], | 487 | [], |
449 | [fixup_tz]) | 488 | [fixup_tz]) |
450 | 489 | ||
451 | |||
452 | dnl ---------------------------------------------------------------------- | 490 | dnl ---------------------------------------------------------------------- | ... | ... |
testsuite/spool/msg.mbox
0 → 100644
1 | From gray@example.org Sat Nov 26 22:45:20 2011 | ||
2 | Date: Sat, 26 Nov 2011 22:45:20 +0200 | ||
3 | From: Sergey Poznyakoff <gray@example.org> | ||
4 | To: <root@example.com> | ||
5 | Subject: rfc2046 | ||
6 | Content-Type: multipart/mixed; boundary="1595057156-1322340286=:8528" | ||
7 | MIME-Version: 1.0 | ||
8 | Status: OR | ||
9 | |||
10 | --1595057156-1322340286=:8528 | ||
11 | Content-ID: <20111126224446.8528.1@host.example.org> | ||
12 | Content-Type: text/plain | ||
13 | |||
14 | An excerpt from RFC 2046 regarding message/rfc822. | ||
15 | |||
16 | |||
17 | --1595057156-1322340286=:8528 | ||
18 | Content-Transfer-Encoding: 7bit | ||
19 | Content-Description: | ||
20 | Content-ID: <20111126224446.8528.1@host.example.org> | ||
21 | Content-Type: message/rfc822; name="1.msg" | ||
22 | |||
23 | Message-ID: <20111123103317.27412@host.example.org> | ||
24 | Date: Wed, 23 Nov 2011 10:33:17 +0200 | ||
25 | From: Sergey Poznyakoff <gray@example.org> | ||
26 | To: <gray@example.com> | ||
27 | Subject: Re: RFC822 Subtype | ||
28 | In-reply-to: Your message of Wed, 23 Nov 2011 08:48:16 +0100 | ||
29 | <87wrar6zzz@example.com> | ||
30 | References: <87wrar6zzz@example.com> | ||
31 | X-Envelope-Date: Wed Nov 23 08:33:17 2011 | ||
32 | X-Envelope-Sender: gray@example.org | ||
33 | |||
34 | 5.2.1. RFC822 Subtype | ||
35 | |||
36 | A media type of "message/rfc822" indicates that the body contains an | ||
37 | encapsulated message, with the syntax of an RFC 822 message. | ||
38 | However, unlike top-level RFC 822 messages, the restriction that each | ||
39 | "message/rfc822" body must include a "From", "Date", and at least one | ||
40 | destination header is removed and replaced with the requirement that | ||
41 | at least one of "From", "Subject", or "Date" must be present. | ||
42 | |||
43 | --1595057156-1322340286=:8528-- | ||
44 |
-
Please register or sign in to post a comment