rmail 0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/NEWS +309 -0
- data/NOTES +14 -0
- data/README +83 -0
- data/THANKS +25 -0
- data/TODO +112 -0
- data/guide/Intro.txt +122 -0
- data/guide/MIME.txt +6 -0
- data/guide/TableOfContents.txt +13 -0
- data/install.rb +1023 -0
- data/lib/rmail.rb +50 -0
- data/lib/rmail/address.rb +829 -0
- data/lib/rmail/header.rb +987 -0
- data/lib/rmail/mailbox.rb +62 -0
- data/lib/rmail/mailbox/mboxreader.rb +182 -0
- data/lib/rmail/message.rb +201 -0
- data/lib/rmail/parser.rb +412 -0
- data/lib/rmail/parser/multipart.rb +217 -0
- data/lib/rmail/parser/pushbackreader.rb +173 -0
- data/lib/rmail/serialize.rb +190 -0
- data/lib/rmail/utils.rb +59 -0
- data/rmail.gemspec +17 -0
- data/tests/addrgrammar.txt +113 -0
- data/tests/data/mbox.odd +4 -0
- data/tests/data/mbox.simple +8 -0
- data/tests/data/multipart/data.1 +5 -0
- data/tests/data/multipart/data.10 +1 -0
- data/tests/data/multipart/data.11 +9 -0
- data/tests/data/multipart/data.12 +9 -0
- data/tests/data/multipart/data.13 +3 -0
- data/tests/data/multipart/data.14 +3 -0
- data/tests/data/multipart/data.15 +3 -0
- data/tests/data/multipart/data.16 +3 -0
- data/tests/data/multipart/data.17 +0 -0
- data/tests/data/multipart/data.2 +5 -0
- data/tests/data/multipart/data.3 +2 -0
- data/tests/data/multipart/data.4 +3 -0
- data/tests/data/multipart/data.5 +1 -0
- data/tests/data/multipart/data.6 +2 -0
- data/tests/data/multipart/data.7 +3 -0
- data/tests/data/multipart/data.8 +5 -0
- data/tests/data/multipart/data.9 +4 -0
- data/tests/data/parser.badmime1 +4 -0
- data/tests/data/parser.badmime2 +6 -0
- data/tests/data/parser.nested-multipart +75 -0
- data/tests/data/parser.nested-simple +12 -0
- data/tests/data/parser.nested-simple2 +16 -0
- data/tests/data/parser.nested-simple3 +21 -0
- data/tests/data/parser.rfc822 +65 -0
- data/tests/data/parser.simple-mime +24 -0
- data/tests/data/parser/multipart.1 +8 -0
- data/tests/data/parser/multipart.10 +4 -0
- data/tests/data/parser/multipart.11 +12 -0
- data/tests/data/parser/multipart.12 +12 -0
- data/tests/data/parser/multipart.13 +6 -0
- data/tests/data/parser/multipart.14 +6 -0
- data/tests/data/parser/multipart.15 +6 -0
- data/tests/data/parser/multipart.16 +6 -0
- data/tests/data/parser/multipart.2 +8 -0
- data/tests/data/parser/multipart.3 +5 -0
- data/tests/data/parser/multipart.4 +6 -0
- data/tests/data/parser/multipart.5 +4 -0
- data/tests/data/parser/multipart.6 +5 -0
- data/tests/data/parser/multipart.7 +6 -0
- data/tests/data/parser/multipart.8 +8 -0
- data/tests/data/parser/multipart.9 +7 -0
- data/tests/data/transparency/absolute.1 +5 -0
- data/tests/data/transparency/absolute.2 +1 -0
- data/tests/data/transparency/absolute.3 +2 -0
- data/tests/data/transparency/absolute.4 +3 -0
- data/tests/data/transparency/absolute.5 +4 -0
- data/tests/data/transparency/absolute.6 +49 -0
- data/tests/data/transparency/message.1 +73 -0
- data/tests/data/transparency/message.2 +34 -0
- data/tests/data/transparency/message.3 +63 -0
- data/tests/data/transparency/message.4 +5 -0
- data/tests/data/transparency/message.5 +15 -0
- data/tests/data/transparency/message.6 +1185 -0
- data/tests/runtests.rb +35 -0
- data/tests/testaddress.rb +1192 -0
- data/tests/testbase.rb +207 -0
- data/tests/testheader.rb +1207 -0
- data/tests/testmailbox.rb +47 -0
- data/tests/testmboxreader.rb +161 -0
- data/tests/testmessage.rb +257 -0
- data/tests/testparser.rb +634 -0
- data/tests/testparsermultipart.rb +205 -0
- data/tests/testpushbackreader.rb +40 -0
- data/tests/testserialize.rb +264 -0
- data/tests/testtestbase.rb +112 -0
- data/tests/testtranspparency.rb +105 -0
- metadata +143 -0
data/lib/rmail/utils.rb
ADDED
@@ -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
|
data/rmail.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = %q{rmail}
|
3
|
+
s.version = "0.17"
|
4
|
+
s.date = Time.now
|
5
|
+
s.summary = %q{This is RubyMail, a lightweight mail library containing various utility classes and modules that allow Ruby scripts to parse, modify, and generate MIME mail messages.}
|
6
|
+
s.author = %q{Matt Armstrong}
|
7
|
+
s.email = %q{matt@lickey.com}
|
8
|
+
s.homepage = %q{http://www.lickey.com/rubymail/}
|
9
|
+
s.has_rdoc = true
|
10
|
+
s.required_ruby_version = Gem::Version::Requirement.new(">= 1.6.7")
|
11
|
+
s.files = Dir.glob('**/*')
|
12
|
+
s.require_path = %q{lib}
|
13
|
+
s.autorequire = %q{rmail}
|
14
|
+
s.test_files = ["tests/runtests.rb"]
|
15
|
+
s.rdoc_options = ["--main", "README"]
|
16
|
+
s.extra_rdoc_files = %w{README NOTES NEWS TODO THANKS}
|
17
|
+
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
|
+
|
data/tests/data/mbox.odd
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--aa--
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
--aa--
|
@@ -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
|
+
|