rmail-sup 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +7 -0
  2. data/NEWS +323 -0
  3. data/NOTES +14 -0
  4. data/README +83 -0
  5. data/Rakefile +184 -0
  6. data/THANKS +25 -0
  7. data/TODO +115 -0
  8. data/guide/Intro.txt +122 -0
  9. data/guide/MIME.txt +6 -0
  10. data/guide/TableOfContents.txt +13 -0
  11. data/install.rb +1023 -0
  12. data/lib/rmail.rb +50 -0
  13. data/lib/rmail/address.rb +841 -0
  14. data/lib/rmail/header.rb +981 -0
  15. data/lib/rmail/mailbox.rb +62 -0
  16. data/lib/rmail/mailbox/mboxreader.rb +182 -0
  17. data/lib/rmail/message.rb +201 -0
  18. data/lib/rmail/parser.rb +412 -0
  19. data/lib/rmail/parser/multipart.rb +217 -0
  20. data/lib/rmail/parser/pushbackreader.rb +173 -0
  21. data/lib/rmail/serialize.rb +190 -0
  22. data/lib/rmail/utils.rb +59 -0
  23. data/test/addrgrammar.txt +113 -0
  24. data/test/data/mbox.odd +4 -0
  25. data/test/data/mbox.simple +8 -0
  26. data/test/data/multipart/data.1 +5 -0
  27. data/test/data/multipart/data.10 +1 -0
  28. data/test/data/multipart/data.11 +9 -0
  29. data/test/data/multipart/data.12 +9 -0
  30. data/test/data/multipart/data.13 +3 -0
  31. data/test/data/multipart/data.14 +3 -0
  32. data/test/data/multipart/data.15 +3 -0
  33. data/test/data/multipart/data.16 +3 -0
  34. data/test/data/multipart/data.17 +0 -0
  35. data/test/data/multipart/data.2 +5 -0
  36. data/test/data/multipart/data.3 +2 -0
  37. data/test/data/multipart/data.4 +3 -0
  38. data/test/data/multipart/data.5 +1 -0
  39. data/test/data/multipart/data.6 +2 -0
  40. data/test/data/multipart/data.7 +3 -0
  41. data/test/data/multipart/data.8 +5 -0
  42. data/test/data/multipart/data.9 +4 -0
  43. data/test/data/parser.badmime1 +4 -0
  44. data/test/data/parser.badmime2 +6 -0
  45. data/test/data/parser.nested-multipart +75 -0
  46. data/test/data/parser.nested-simple +12 -0
  47. data/test/data/parser.nested-simple2 +16 -0
  48. data/test/data/parser.nested-simple3 +21 -0
  49. data/test/data/parser.rfc822 +65 -0
  50. data/test/data/parser.simple-mime +24 -0
  51. data/test/data/parser/multipart.1 +8 -0
  52. data/test/data/parser/multipart.10 +4 -0
  53. data/test/data/parser/multipart.11 +12 -0
  54. data/test/data/parser/multipart.12 +12 -0
  55. data/test/data/parser/multipart.13 +6 -0
  56. data/test/data/parser/multipart.14 +6 -0
  57. data/test/data/parser/multipart.15 +6 -0
  58. data/test/data/parser/multipart.16 +6 -0
  59. data/test/data/parser/multipart.2 +8 -0
  60. data/test/data/parser/multipart.3 +5 -0
  61. data/test/data/parser/multipart.4 +6 -0
  62. data/test/data/parser/multipart.5 +4 -0
  63. data/test/data/parser/multipart.6 +5 -0
  64. data/test/data/parser/multipart.7 +6 -0
  65. data/test/data/parser/multipart.8 +8 -0
  66. data/test/data/parser/multipart.9 +7 -0
  67. data/test/data/transparency/absolute.1 +5 -0
  68. data/test/data/transparency/absolute.2 +1 -0
  69. data/test/data/transparency/absolute.3 +2 -0
  70. data/test/data/transparency/absolute.4 +3 -0
  71. data/test/data/transparency/absolute.5 +4 -0
  72. data/test/data/transparency/absolute.6 +49 -0
  73. data/test/data/transparency/message.1 +73 -0
  74. data/test/data/transparency/message.2 +34 -0
  75. data/test/data/transparency/message.3 +63 -0
  76. data/test/data/transparency/message.4 +5 -0
  77. data/test/data/transparency/message.5 +15 -0
  78. data/test/data/transparency/message.6 +1185 -0
  79. data/test/runtests.rb +35 -0
  80. data/test/testaddress.rb +1204 -0
  81. data/test/testbase.rb +204 -0
  82. data/test/testheader.rb +1225 -0
  83. data/test/testmailbox.rb +47 -0
  84. data/test/testmboxreader.rb +161 -0
  85. data/test/testmessage.rb +257 -0
  86. data/test/testparser.rb +634 -0
  87. data/test/testparsermultipart.rb +205 -0
  88. data/test/testpushbackreader.rb +40 -0
  89. data/test/testserialize.rb +264 -0
  90. data/test/testtestbase.rb +116 -0
  91. data/test/testtranspparency.rb +105 -0
  92. data/version +1 -0
  93. metadata +149 -0
@@ -0,0 +1,59 @@
1
+ #--
2
+ # Copyright (C) 2002, 2003 Matt Armstrong. All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
6
+ #
7
+ # 1. Redistributions of source code must retain the above copyright notice,
8
+ # this list of conditions and the following disclaimer.
9
+ # 2. Redistributions in binary form must reproduce the above copyright
10
+ # notice, this list of conditions and the following disclaimer in the
11
+ # documentation and/or other materials provided with the distribution.
12
+ # 3. The name of the author may not be used to endorse or promote products
13
+ # derived from this software without specific prior written permission.
14
+ #
15
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16
+ # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17
+ # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
18
+ # NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
20
+ # TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21
+ # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
22
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ #
26
+ #++
27
+ # Implements the RMail::Utils module.
28
+
29
+ module RMail
30
+
31
+ # The RMail::Utils module is a collection of random utility methods
32
+ # that are useful for dealing with email.
33
+ module Utils
34
+
35
+ class << self
36
+
37
+ # Return the given string unquoted if it is quoted.
38
+ def unquote(str)
39
+ if str =~ /\s*"(.*?([^\\]|\\\\))"/m
40
+ $1.gsub(/\\(.)/, '\1')
41
+ else
42
+ str
43
+ end
44
+ end
45
+
46
+ # Decode the given string as if it were a chunk of base64 data
47
+ def base64_decode(str)
48
+ str.unpack("m*").first
49
+ end
50
+
51
+ # Decode the given string as if it were a chunk of quoted
52
+ # printable data
53
+ def quoted_printable_decode(str)
54
+ str.unpack("M*").first
55
+ end
56
+
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,113 @@
1
+ Primarily concerned about mailbox, mailbox-list, and address-list
2
+
3
+ mailbox - sender, resent-sender
4
+
5
+ mailbox-list - from, resent-from
6
+
7
+ address-list - reply-to, to, cc, bcc, resent-to, resent-cc, resent-bcc
8
+
9
+ ----------------------------------------------------------------------
10
+ Tokens
11
+ ----------------------------------------------------------------------
12
+
13
+ Primitive -- these do not appear in Address Spedifications
14
+ ----------------------------------------------------------------------
15
+
16
+ NO-WS-CTL = %d1-8 / ; US-ASCII control characters
17
+ %d11 / ; that do not include the
18
+ %d12 / ; carriage return, line feed,
19
+ %d14-31 / ; and white space characters
20
+ %d127
21
+
22
+ atext = a-z / A-Z / ; Any character except controls,
23
+ 0-9 /
24
+ "!" / "#" / ; SP, and specials.
25
+ "$" / "%" / ; Used for atoms
26
+ "&" / "'" /
27
+ "*" / "+" /
28
+ "-" / "/" /
29
+ "=" / "?" /
30
+ "^" / "_" /
31
+ "`" / "{" /
32
+ "|" / "}" /
33
+ "~"
34
+
35
+ quoted-pair = "\" (%d0-127)
36
+
37
+ qtext = NO-WS-CTL / ; Non white space controls
38
+ %d33 / ; The rest of the US-ASCII
39
+ %d35-91 / ; characters not including "\"
40
+ %d93-126 ; or the quote character
41
+
42
+ WSP = %d32 / %d09 ; SPACE or TAB
43
+
44
+ ctext = NO-WS-CTL / ; Non white space controls
45
+ %d33-39 / ; The rest of the US-ASCII
46
+ %d42-91 / ; characters not including "(",
47
+ %d93-126 ; ")", or "\"
48
+
49
+ comment = "(" *([FWS] ccontent) [FWS] ")"
50
+
51
+ ccontent = ctext / quoted-pair / comment
52
+
53
+ qcontent = qtext / quoted-pair
54
+
55
+ dtext = NO-WS-CTL / ; Non white space controls
56
+ %d33-90 / ; The rest of the US-ASCII
57
+ %d94-126 ; characters not including "[",
58
+ ; "]", or "\"
59
+
60
+ Less primitive - these appear in Address Specifications
61
+ ----------------------------------------------------------------------
62
+
63
+ FWS = 1*([CRLF] WSP)
64
+
65
+ CFWS = *([FWS] comment) (([FWS] comment) / FWS)
66
+
67
+ atom = [CFWS] 1*atext [CFWS]
68
+
69
+ quoted-string = [CFWS]
70
+ " *([FWS] qcontent) [FWS] "
71
+ [CFWS]
72
+
73
+ phrase = word *(word / "." / CFWS)
74
+
75
+ word = atom / quoted-string
76
+
77
+ dcontent = dtext / quoted-pair
78
+
79
+ ----------------------------------------------------------------------
80
+ Address Specification
81
+ ----------------------------------------------------------------------
82
+
83
+ address-list = 1*([address] [CFWS] "," [CFWS]) [address]
84
+
85
+ address = mailbox / group
86
+
87
+ mailbox = name-addr / addr-spec
88
+
89
+ group = display-name ":" [mailbox-list / CFWS] ";"
90
+ [CFWS]
91
+
92
+ mailbox-list = 1*([mailbox] [CFWS] "," [CFWS]) [mailbox]
93
+
94
+ name-addr = [display-name] angle-addr
95
+
96
+ display-name = phrase
97
+
98
+ angle-addr = [CFWS] "<" [obs-route] addr-spec ">" [CFWS]
99
+
100
+ obs-route = [CFWS] obs-domain-list ":" [CFWS]
101
+
102
+ obs-domain-list = "@" domain *(*(CFWS / "," ) [CFWS] "@" domain)
103
+
104
+ domain = domain-literal / obs-domain
105
+
106
+ domain-literal = [CFWS] "[" *([FWS] dcontent) [FWS] "]" [CFWS]
107
+
108
+ obs-domain = atom *("." atom)
109
+
110
+ addr-spec = local-part "@" domain
111
+
112
+ local-part = word *("." word)
113
+
@@ -0,0 +1,4 @@
1
+ From foo@bar Wed Nov 27 12:27:36 2002
2
+ message1
3
+ From foo@bar Wed Nov 27 12:27:40 2002
4
+ message2
@@ -0,0 +1,8 @@
1
+ From foo@bar Wed Nov 27 12:27:32 2002
2
+ message1
3
+
4
+ From foo@bar Wed Nov 27 12:27:36 2002
5
+ message2
6
+
7
+ From foo@bar Wed Nov 27 12:27:40 2002
8
+ message3
@@ -0,0 +1,5 @@
1
+ preamble
2
+ --aa
3
+ part1
4
+ --aa--
5
+ epilogue
@@ -0,0 +1 @@
1
+ --aa--
@@ -0,0 +1,9 @@
1
+ preamble
2
+ --aa
3
+ part1
4
+ --aa
5
+ part2
6
+ --aa
7
+ part3
8
+ --aa--
9
+ epilogue
@@ -0,0 +1,9 @@
1
+ preamble
2
+ --aaZ
3
+ part1
4
+ --aa notignored
5
+ part2
6
+ --aa notignored
7
+ part3
8
+ --aa--notignored
9
+ epilogue
@@ -0,0 +1,3 @@
1
+ preamble
2
+ --aa
3
+ part1
@@ -0,0 +1,3 @@
1
+ preamble
2
+ --aa
3
+ part1
@@ -0,0 +1,3 @@
1
+ preamble
2
+ line1
3
+ line2
@@ -0,0 +1,3 @@
1
+ preamble
2
+ line1
3
+ line2
File without changes
@@ -0,0 +1,5 @@
1
+
2
+ --aa
3
+
4
+ --aa--
5
+
@@ -0,0 +1,2 @@
1
+ --aa
2
+ --aa--
@@ -0,0 +1,3 @@
1
+ preamble
2
+ --aa--
3
+ epilogue
@@ -0,0 +1 @@
1
+ --aa--
@@ -0,0 +1,2 @@
1
+
2
+ --aa--
@@ -0,0 +1,3 @@
1
+ preamble
2
+
3
+ --aa--
@@ -0,0 +1,5 @@
1
+ preamble
2
+ --aa
3
+ part1
4
+ --aa--
5
+ epilogue
@@ -0,0 +1,4 @@
1
+
2
+ --aa
3
+
4
+ --aa--
@@ -0,0 +1,4 @@
1
+ MIME-Version: 1.0
2
+ Content-Type: multipart/alternative; boundary=X
3
+
4
+ --X--
@@ -0,0 +1,6 @@
1
+ MIME-Version: 1.0
2
+ Content-Type: multipart/alternative; boundary=X
3
+
4
+ preamble
5
+ --X--
6
+ epilogue
@@ -0,0 +1,75 @@
1
+ Return-Path: <matt@lickey.com>
2
+ Delivered-To: matt@lickey.com
3
+ Received: from localhost (localhost [127.0.0.1])
4
+ by squeaker.lickey.com (Postfix) with ESMTP id 78B08C0BE
5
+ for <matt@lickey.com>; Thu, 7 Feb 2002 19:35:13 -0700 (MST)
6
+ Received: by squeaker.lickey.com (Postfix, from userid 1000)
7
+ id 52497BE6D; Thu, 7 Feb 2002 19:35:12 -0700 (MST)
8
+ To: matt@lickey.com
9
+ Subject: Some nested multiparts
10
+ From: Matt Armstrong <matt@lickey.com>
11
+ Date: Thu, 07 Feb 2002 19:35:11 -0700
12
+ X-Gnus-Mail-Source: directory:~/.incoming
13
+ Message-ID: <877kpolmzk.fsf@squeaker.lickey.com>
14
+ User-Agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.1
15
+ (i386-debian-linux-gnu)
16
+ MIME-Version: 1.0
17
+ Content-Type: multipart/mixed; boundary="=-=-="
18
+ X-Virus-Scanned: by AMaViS snapshot-20010714
19
+ Lines: 45
20
+ Xref: squeaker.lickey.com inbox:7709
21
+
22
+ This is level 1's preamble.
23
+
24
+ --=-=-=
25
+
26
+ Let's see here.
27
+
28
+ --=-=-=
29
+ Content-Disposition: inline
30
+
31
+ This is the first part.
32
+
33
+ --=-=-=
34
+ Content-Type: multipart/mixed; boundary="==-=-="
35
+
36
+ This is level 2's preamble.
37
+
38
+ --==-=-=
39
+ Content-Disposition: inline
40
+
41
+ This is the first nested part.
42
+
43
+ --==-=-=
44
+ Content-Disposition: inline
45
+
46
+ This is the second nested part.
47
+
48
+ --==-=-=
49
+ Content-Type: multipart/mixed; boundary="===-=-="
50
+
51
+ This is level 3's preamble.
52
+
53
+ --===-=-=
54
+
55
+ This is the first doubly nested part.
56
+
57
+ --===-=-=
58
+ Content-Disposition: inline
59
+
60
+ This is the second doubly nested part.
61
+
62
+ --===-=-=--
63
+ This is level 3's epilogue.
64
+
65
+ --==-=-=--
66
+ This is level 2's epilogue. It has no trailing end of line.
67
+ --=-=-=
68
+ Content-Disposition: inline
69
+
70
+ This is the third part.
71
+
72
+ --=-=-=--
73
+
74
+ This is level 1's epilogue.
75
+
@@ -0,0 +1,12 @@
1
+ Content-Type: multipart/mixed; boundary="=-=-="
2
+ MIME-Version: 1.0
3
+
4
+ --=-=-=
5
+ Content-Type: multipart/mixed; boundary="==-=-="
6
+
7
+ --==-=-=
8
+
9
+ --==-=-=
10
+
11
+ --==-=-=--
12
+ --=-=-=--
@@ -0,0 +1,16 @@
1
+ Content-Type: multipart/mixed; boundary="=-=-="
2
+ MIME-Version: 1.0
3
+
4
+
5
+ --=-=-=
6
+ Content-Type: multipart/mixed; boundary="==-=-="
7
+
8
+
9
+ --==-=-=
10
+
11
+ --==-=-=
12
+
13
+ --==-=-=--
14
+
15
+ --=-=-=--
16
+
@@ -0,0 +1,21 @@
1
+ Content-Type: multipart/mixed; boundary="X"
2
+ MIME-Version: 1.0
3
+
4
+
5
+
6
+ --X
7
+ Content-Type: multipart/mixed; boundary="Y"
8
+
9
+
10
+
11
+ --Y
12
+
13
+ --Y
14
+
15
+
16
+ --Y--
17
+
18
+
19
+ --X--
20
+
21
+
@@ -0,0 +1,65 @@
1
+ Return-Path: <matt@lickey.com>
2
+ Delivered-To: matt@lickey.com
3
+ Received: from localhost (localhost [127.0.0.1])
4
+ by squeaker.lickey.com (Postfix) with ESMTP id B9ED0C0E7
5
+ for <matt@lickey.com>; Sun, 10 Feb 2002 14:35:43 -0700 (MST)
6
+ Received: by squeaker.lickey.com (Postfix, from userid 1000)
7
+ id BE69CC0D1; Sun, 10 Feb 2002 14:35:37 -0700 (MST)
8
+ To: matt@lickey.com
9
+ Subject: Example of a message/rfc822 part.
10
+ From: Matt Armstrong <matt@lickey.com>
11
+ Date: Sun, 10 Feb 2002 14:35:37 -0700
12
+ X-Gnus-Mail-Source: directory:~/.incoming
13
+ Message-ID: <87heop10ly.fsf@squeaker.lickey.com>
14
+ User-Agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.1
15
+ (i386-debian-linux-gnu)
16
+ MIME-Version: 1.0
17
+ Content-Type: multipart/mixed; boundary="=-=-="
18
+ X-Virus-Scanned: by AMaViS snapshot-20010714
19
+ Lines: 44
20
+ Xref: squeaker.lickey.com inbox:7729
21
+
22
+ --=-=-=
23
+
24
+ Below is an example of a message/rfc822 MIME part.
25
+
26
+
27
+ --=-=-=
28
+ Content-Type: message/rfc822
29
+ Content-Disposition: inline
30
+
31
+ Return-Path: <matt@lickey.com>
32
+ Delivered-To: matt@lickey.com
33
+ Received: from localhost (localhost [127.0.0.1])
34
+ by squeaker.lickey.com (Postfix) with ESMTP id 5F0B4C0E7
35
+ for <matt@lickey.com>; Sun, 10 Feb 2002 14:34:31 -0700 (MST)
36
+ Received: by squeaker.lickey.com (Postfix, from userid 1000)
37
+ id F0DABC0D1; Sun, 10 Feb 2002 14:34:29 -0700 (MST)
38
+ To: matt@lickey.com
39
+ Subject: This is a short, simple message.
40
+ From: Matt Armstrong <matt@lickey.com>
41
+ Date: Sun, 10 Feb 2002 14:34:29 -0700
42
+ Message-ID: <87n0yh10nu.fsf@squeaker.lickey.com>
43
+ User-Agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.1
44
+ (i386-debian-linux-gnu)
45
+ X-Virus-Scanned: by AMaViS snapshot-20010714
46
+ Lines: 5
47
+ Xref: squeaker.lickey.com inbox:7728
48
+ MIME-Version: 1.0
49
+
50
+ This is a short, simple message.
51
+
52
+ --
53
+ matt
54
+
55
+
56
+ --=-=-=
57
+
58
+
59
+
60
+ --
61
+ matt
62
+
63
+ --=-=-=--
64
+
65
+