rmail 1.0.0 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/{NEWS → ChangeLog} +42 -0
- data/{README → README.md} +20 -43
- data/Rakefile +52 -68
- data/lib/rmail/address.rb +17 -5
- data/lib/rmail/header.rb +16 -12
- data/lib/rmail/message.rb +3 -2
- data/lib/rmail/parser.rb +4 -3
- data/lib/rmail/parser/pushbackreader.rb +7 -7
- data/lib/rmail/serialize.rb +1 -1
- data/lib/rmail/version.rb +3 -0
- data/test/testaddress.rb +23 -11
- data/test/testbase.rb +21 -1
- data/test/testheader.rb +21 -13
- data/test/testmessage.rb +1 -1
- metadata +62 -75
- data/install.rb +0 -1023
- data/version +0 -1
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 419bee362a39a953f99c8e6ff8adbbc1c921df6a4db9bb64f549ec6ed6a6ba3b
|
4
|
+
data.tar.gz: f93bce83b84092e1c05ef2472f1d1936b03ad7ff5ef398b2f85dd61eff5f726c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e3084bf084c2be23361db1cdc21321f623ab32e486ff3a101516d8f12999853c6650158b6082208320b79fd638bc51e7b06952bab9f41c2013b0675697e11e91
|
7
|
+
data.tar.gz: 4801d74331dfa38682cb4484f16f5cb9f07704bb8305fa5dcb2e3a42a10460e912327c63a00a7f02b92e1ffc2a7d653cfa33cf7c45bc4b055b3c6d4e29fcd95c
|
data/{NEWS → ChangeLog}
RENAMED
@@ -1,3 +1,45 @@
|
|
1
|
+
= Changes in RubyMail 1.1.4 (released 2020-07-08)
|
2
|
+
|
3
|
+
- Fix 'warning: constant ::Fixnum is deprecated' since Ruby 2.5 (Martin Vidner)
|
4
|
+
- Fix 'warning: instance variable @delimiters not initialized' (Martin Vidner)
|
5
|
+
- Fix 'warning: shadowing outer local variable - name, value' (Martin Vidner)
|
6
|
+
- Fix 'warning: optional boolean argument is obsoleted' (Martin Vidner)
|
7
|
+
- Fix 'warning: character class has duplicated range' (Martin Vidner)
|
8
|
+
- Fix 'warning: assigned but unused variable' (Martin Vidner)
|
9
|
+
- Enable code coverage analysis (Martin Vidner)
|
10
|
+
- Test Ruby 2.5 and 2.6 on Travis (Martin Vidner)
|
11
|
+
- Test Ruby 2.7 (Martin Vidner)
|
12
|
+
- include license text in a separate file (Dan Callaghan)
|
13
|
+
- Rakefile: drop usage of deprecated rubygems feature (Antonio Terceiro)
|
14
|
+
|
15
|
+
= Changes in RubyMail 1.1.3 (released 2017-07-16)
|
16
|
+
|
17
|
+
- Fix tests that suddenly started failing for no apparent reason
|
18
|
+
|
19
|
+
= Changes in RubyMail 1.1.2 (released 2016-01-17)
|
20
|
+
|
21
|
+
- Fix crash on invalid header encodings (Github issue #7)
|
22
|
+
|
23
|
+
= Changes in RubyMail 1.1.1 (released 2015-11-30)
|
24
|
+
|
25
|
+
- README.md updated (and renamed from README). Thanks to Aldric Giacomoni and
|
26
|
+
Zeger-Jan van de Weg
|
27
|
+
- Fix crash against empty "Content-Type" header. Thanks to Matthew Bloch
|
28
|
+
|
29
|
+
= Changes in RubyMail 1.1.0 (released 2015-02-10)
|
30
|
+
|
31
|
+
- This version contains fixes for running on Ruby 2.0+ that were contributed by
|
32
|
+
Josef Stribny, plus 7 patches that have accumulated in the Debian package of
|
33
|
+
rmail over the years by Adeodato Simó, Per Andersson, and Antonio Terceiro.
|
34
|
+
There are also a few fixes by the original author Matt Armstrong that never
|
35
|
+
made it into a release.
|
36
|
+
- This version is mostly compatible with 1.0.0, but since it wasn't explicitly
|
37
|
+
tested on older RUby releases we bumping the minor version as a warning to
|
38
|
+
users.
|
39
|
+
- Rakefile was updated to actually run on modern Ruby versions
|
40
|
+
- The tests were fixed for Ruby 2.0+ compatibility
|
41
|
+
- The version number was moved to lib/rmail/version.rb
|
42
|
+
|
1
43
|
= Changes in RubyMail 1.0.0 (released 2008-01-05)
|
2
44
|
|
3
45
|
- This version differs *only* in the changes required for Ruby 1.9
|
data/{README → README.md}
RENAMED
@@ -1,64 +1,41 @@
|
|
1
|
-
|
1
|
+
# RubyMail
|
2
2
|
|
3
3
|
This is RubyMail, a lightweight mail library containing various
|
4
4
|
utility classes and modules that allow Ruby scripts to parse,
|
5
5
|
modify, and generate MIME mail messages.
|
6
6
|
|
7
|
-
|
7
|
+
## Requirements
|
8
8
|
|
9
|
-
Ruby
|
10
|
-
be fine under any Unix.
|
9
|
+
Ruby 2.0 or newer is supported.
|
11
10
|
|
12
|
-
|
11
|
+
## Install
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
```bash
|
14
|
+
gem install rmail
|
15
|
+
```
|
17
16
|
|
18
|
-
|
17
|
+
## Status
|
19
18
|
|
20
|
-
|
19
|
+
[![Build Status](https://travis-ci.org/terceiro/rmail.svg?branch=master)](https://travis-ci.org/terceiro/rmail)
|
21
20
|
|
22
|
-
ruby install.rb config
|
23
|
-
ruby install.rb setup
|
24
|
-
ruby install.rb install
|
25
21
|
|
26
|
-
|
27
|
-
want to just install RubyMail to a custom location, just copy the
|
28
|
-
rmail subdirectory manually.
|
22
|
+
## Tests
|
29
23
|
|
30
|
-
|
24
|
+
This package has a complete unit test suite. To run it, just run `rake` under
|
25
|
+
the top-level directory. When submitting patches, please make sure all the
|
26
|
+
tests pass with your changes applied.
|
31
27
|
|
32
|
-
|
28
|
+
## Support
|
33
29
|
|
34
|
-
|
35
|
-
|
30
|
+
If you found a bug, or even if you think you did but is not completely sure,
|
31
|
+
open an issue on the [issue tracker](https://github.com/terceiro/rmail/issues).
|
36
32
|
|
37
|
-
|
33
|
+
## License
|
38
34
|
|
39
|
-
|
40
|
-
|
35
|
+
Copyright (C) 2001, 2002, 2003, 2004 Matt Armstrong.
|
36
|
+
Copyright (C) 2015 Antonio Terceiro.
|
37
|
+
All rights reserved.
|
41
38
|
|
42
|
-
= Why?
|
43
|
-
|
44
|
-
It is fun.
|
45
|
-
|
46
|
-
One use for RubyMail is the RubyFilter package, available at:
|
47
|
-
|
48
|
-
http://www.lickey.com/rubyfilter/
|
49
|
-
|
50
|
-
= Alternatives
|
51
|
-
|
52
|
-
You might check out TMail as well.
|
53
|
-
|
54
|
-
= Support
|
55
|
-
|
56
|
-
To reach the author of RubyMail, send mail to matt@lickey.com.
|
57
|
-
|
58
|
-
= License
|
59
|
-
|
60
|
-
Copyright (C) 2001, 2002, 2003, 2004 Matt Armstrong. All rights
|
61
|
-
reserved.
|
62
39
|
|
63
40
|
Redistribution and use in source and binary forms, with or without
|
64
41
|
modification, are permitted provided that the following conditions are met:
|
data/Rakefile
CHANGED
@@ -4,12 +4,8 @@
|
|
4
4
|
# This is a Ruby file, used by the "rake" make-like program.
|
5
5
|
#
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
require 'rubygems'
|
10
|
-
require 'rake/gempackagetask'
|
11
|
-
end
|
12
|
-
require 'rake/rdoctask'
|
7
|
+
require 'rubygems/package_task'
|
8
|
+
require 'rdoc/task'
|
13
9
|
require 'rake/testtask'
|
14
10
|
require 'shellwords'
|
15
11
|
|
@@ -23,7 +19,7 @@ task :default => :test
|
|
23
19
|
# Test tasks
|
24
20
|
#
|
25
21
|
Rake::TestTask.new do |t|
|
26
|
-
t.libs << '
|
22
|
+
t.libs << '.'
|
27
23
|
t.pattern = 'test/test*.rb'
|
28
24
|
t.verbose = true
|
29
25
|
end
|
@@ -38,7 +34,7 @@ def can_release_package
|
|
38
34
|
reasons = []
|
39
35
|
|
40
36
|
unless news_is_current
|
41
|
-
reasons << 'the
|
37
|
+
reasons << 'the ChangeLog file is not current'
|
42
38
|
end
|
43
39
|
|
44
40
|
unless defined?(Gem)
|
@@ -67,11 +63,11 @@ def can_release_package
|
|
67
63
|
can_release_package
|
68
64
|
end
|
69
65
|
|
70
|
-
# Is
|
66
|
+
# Is ChangeLog current?
|
71
67
|
def news_is_current
|
72
68
|
today = Time.now.strftime('%Y-%m-%d')
|
73
69
|
version = Regexp.new(Regexp.quote(PKG_VERSION))
|
74
|
-
if IO.readlines('
|
70
|
+
if IO.readlines('ChangeLog').first =~
|
75
71
|
/= Changes in RubyMail #{PKG_VERSION} \(released #{today}\)$/
|
76
72
|
true
|
77
73
|
else
|
@@ -83,34 +79,25 @@ end
|
|
83
79
|
#
|
84
80
|
# These PKG_ variables are used by Rake's package rule.
|
85
81
|
#
|
86
|
-
|
87
|
-
|
88
|
-
if version =~ /^\d+\.\d+\.\d+$/
|
89
|
-
version.untaint
|
90
|
-
else
|
91
|
-
fail "package version is bogus"
|
92
|
-
end
|
93
|
-
version
|
94
|
-
end
|
82
|
+
require './lib/rmail/version.rb'
|
83
|
+
PKG_VERSION = RMail::VERSION
|
95
84
|
|
96
85
|
PKG_FILES = FileList.new('test/**/*',
|
97
86
|
'guide/**/*',
|
98
87
|
'lib/**/*',
|
99
|
-
'
|
100
|
-
'NEWS',
|
88
|
+
'ChangeLog',
|
101
89
|
'NOTES',
|
102
|
-
'README',
|
90
|
+
'README.md',
|
103
91
|
'THANKS',
|
104
92
|
'TODO',
|
105
|
-
'Rakefile'
|
106
|
-
'version')
|
93
|
+
'Rakefile')
|
107
94
|
|
108
95
|
#
|
109
96
|
# Teach Rake how to build the RDoc documentation for this package.
|
110
97
|
#
|
111
98
|
rdoc = Rake::RDocTask.new do |rdoc|
|
112
99
|
rdoc.main = 'README'
|
113
|
-
rdoc.rdoc_files.include("README", "
|
100
|
+
rdoc.rdoc_files.include("README.md", "ChangeLog", "THANKS",
|
114
101
|
"TODO", "guide/*.txt", "lib/**/*.rb")
|
115
102
|
rdoc.rdoc_files.exclude(/\bSCCS\b/,
|
116
103
|
"lib/rubymail/parser/*")
|
@@ -136,51 +123,48 @@ end
|
|
136
123
|
#
|
137
124
|
# Create a Gem::Specification right in the Rakefile, using some of the
|
138
125
|
# variables we have set up above.
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
s.email = "matt@rfc20.org"
|
168
|
-
s.homepage = "http://www.rfc20.org/rubymail"
|
169
|
-
|
170
|
-
s.rubyforge_project = "rubymail"
|
171
|
-
end
|
126
|
+
spec = Gem::Specification.new do |s|
|
127
|
+
s.name = 'rmail'
|
128
|
+
s.version = PKG_VERSION + if can_release_package
|
129
|
+
''
|
130
|
+
else
|
131
|
+
'.666'
|
132
|
+
end
|
133
|
+
s.summary = 'A MIME mail parsing and generation library.'
|
134
|
+
s.description = <<-EOF
|
135
|
+
RMail is a lightweight mail library containing various utility classes and
|
136
|
+
modules that allow ruby scripts to parse, modify, and generate MIME mail
|
137
|
+
messages.
|
138
|
+
EOF
|
139
|
+
|
140
|
+
s.files = PKG_FILES.to_a
|
141
|
+
|
142
|
+
s.required_ruby_version = Gem::Version::Requirement.new(">= 1.8.1")
|
143
|
+
|
144
|
+
s.extra_rdoc_files = rdoc.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
|
145
|
+
s.rdoc_options.concat([ '--title', rdoc.title, '--main', rdoc.main,
|
146
|
+
rdoc.options ].flatten)
|
147
|
+
|
148
|
+
s.test_files = FileList['test/tc_*.rb'].to_a
|
149
|
+
|
150
|
+
s.author = ["Matt Armstrong", "Antonio Terceiro"]
|
151
|
+
s.email = "terceiro@softwarelivre.org"
|
152
|
+
s.homepage = "https://github.com/terceiro/rmail"
|
153
|
+
end
|
172
154
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
end
|
155
|
+
#
|
156
|
+
# Use our Gem::Specification to make some package tasks.
|
157
|
+
#
|
158
|
+
Gem::PackageTask.new(spec) do |pkg|
|
159
|
+
pkg.need_zip = true
|
160
|
+
pkg.need_tar = true
|
180
161
|
end
|
181
162
|
|
182
|
-
desc
|
183
|
-
task :
|
184
|
-
|
163
|
+
desc 'Makes a release'
|
164
|
+
task :release => [:test, :package] do
|
165
|
+
sh 'git', 'tag', '-s', "v#{PKG_VERSION}"
|
166
|
+
sh 'git', 'push'
|
167
|
+
sh 'git', 'push', '--tags'
|
168
|
+
sh 'gem', 'push', "pkg/rmail-#{PKG_VERSION}.gem"
|
185
169
|
end
|
186
170
|
|
data/lib/rmail/address.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright (C) 2001, 2002, 2003 Matt Armstrong. All rights
|
2
|
+
# Copyright (C) 2001, 2002, 2003, 2008 Matt Armstrong. All rights
|
3
3
|
# reserved.
|
4
4
|
#
|
5
5
|
# Redistribution and use in source and binary forms, with or without
|
@@ -50,7 +50,6 @@ module RMail
|
|
50
50
|
# is parsed for mail addresses and if one is found, it is used to
|
51
51
|
# initialize this object.
|
52
52
|
def initialize(string = nil)
|
53
|
-
|
54
53
|
@local = @domain = @comments = @display_name = nil
|
55
54
|
|
56
55
|
if string.kind_of?(String)
|
@@ -421,7 +420,6 @@ module RMail
|
|
421
420
|
# local-part ':' -> it is a display-name of a group
|
422
421
|
# display-name '<' -> it is a mailbox display name
|
423
422
|
# display-name ':' -> it is a group display name
|
424
|
-
#
|
425
423
|
|
426
424
|
# set lookahead to '@' '<' or ':' (or another value for
|
427
425
|
# invalid input)
|
@@ -472,6 +470,20 @@ module RMail
|
|
472
470
|
@addresses.last.local = get_text
|
473
471
|
expect(SYM_AT_SIGN)
|
474
472
|
domain
|
473
|
+
|
474
|
+
if @sym == SYM_LESS_THAN
|
475
|
+
# Workaround for invalid input. Treat 'foo@bar <foo@bar>' as if it
|
476
|
+
# were '"foo@bar" <foo@bar>'. The domain parser will eat
|
477
|
+
# 'bar' but stop at '<'. At this point, we've been
|
478
|
+
# parsing the display name as if it were an address, so we
|
479
|
+
# throw the address into display_name and parse an
|
480
|
+
# angle_addr.
|
481
|
+
@addresses.last.display_name =
|
482
|
+
format("%s@%s", @addresses.last.local, @addresses.last.domain)
|
483
|
+
@addresses.last.local = nil
|
484
|
+
@addresses.last.domain = nil
|
485
|
+
angle_addr
|
486
|
+
end
|
475
487
|
end
|
476
488
|
end
|
477
489
|
|
@@ -649,7 +661,7 @@ module RMail
|
|
649
661
|
comment
|
650
662
|
when /\A""/ # skip empty quoted text
|
651
663
|
@string = $'
|
652
|
-
when /\A[\w!$%&\'
|
664
|
+
when /\A[\w!$%&\'*+\/=?^\`{\}|~#-]+/m
|
653
665
|
@string = $'
|
654
666
|
@sym = SYM_ATOM
|
655
667
|
break
|
@@ -691,7 +703,7 @@ module RMail
|
|
691
703
|
@sym = SYM_DOMAIN_LITERAL
|
692
704
|
@lexeme = $1.gsub(/(^|[^\\])[\r\n\t ]+/, '\1').gsub(/\\(.)/, '\1')
|
693
705
|
break
|
694
|
-
when /\A[\200-\377\w!$%&\'
|
706
|
+
when /\A[\200-\377\w!$%&\'*+\/=?^\`{\}|~#-]+/nm
|
695
707
|
# This is just like SYM_ATOM, but includes all characters
|
696
708
|
# with high bits. This is so we can allow such tokens in
|
697
709
|
# the display name portion of an address even though it
|
data/lib/rmail/header.rb
CHANGED
@@ -73,7 +73,10 @@ module RMail
|
|
73
73
|
|
74
74
|
class Field # :nodoc:
|
75
75
|
# fixme, document methadology for this (RFC2822)
|
76
|
-
|
76
|
+
|
77
|
+
# accoring to RFC2822 the header field name can consist of any
|
78
|
+
# ASCII char between and including 33 and 126.
|
79
|
+
EXTRACT_FIELD_NAME_RE = /\A(^\w[-\w]+):\s*/o
|
77
80
|
|
78
81
|
class << self
|
79
82
|
def parse(field)
|
@@ -133,10 +136,10 @@ module RMail
|
|
133
136
|
end
|
134
137
|
|
135
138
|
# Return the value of the first matching field of a field name, or
|
136
|
-
# nil if none found. If passed
|
139
|
+
# nil if none found. If passed an Integer, returns the header
|
137
140
|
# indexed by the number.
|
138
141
|
def [](name_or_index)
|
139
|
-
if name_or_index.kind_of?
|
142
|
+
if name_or_index.kind_of? Integer
|
140
143
|
temp = @fields[name_or_index]
|
141
144
|
temp = temp.value unless temp.nil?
|
142
145
|
else
|
@@ -471,9 +474,9 @@ module RMail
|
|
471
474
|
#
|
472
475
|
# See also: #match
|
473
476
|
def match?(name, value)
|
474
|
-
massage_match_args(name, value) { |
|
477
|
+
massage_match_args(name, value) { |mname, mvalue|
|
475
478
|
match = detect {|n, v|
|
476
|
-
n =~
|
479
|
+
n =~ mname && v =~ mvalue
|
477
480
|
}
|
478
481
|
! match.nil?
|
479
482
|
}
|
@@ -504,10 +507,10 @@ module RMail
|
|
504
507
|
#
|
505
508
|
# See also: #match?
|
506
509
|
def match(name, value)
|
507
|
-
massage_match_args(name, value) { |
|
510
|
+
massage_match_args(name, value) { |mname, mvalue|
|
508
511
|
header = RMail::Header.new
|
509
|
-
|
510
|
-
if n.downcase =~
|
512
|
+
each { |n, v|
|
513
|
+
if n.downcase =~ mname && mvalue =~ v
|
511
514
|
header[n] = v
|
512
515
|
end
|
513
516
|
}
|
@@ -533,8 +536,9 @@ module RMail
|
|
533
536
|
# executed and its return value is returned. If no block is passed,
|
534
537
|
# the value of the +default+ argument is returned.
|
535
538
|
def content_type(default = nil)
|
536
|
-
|
537
|
-
|
539
|
+
content_type = self['content-type']
|
540
|
+
if content_type && content_type.length > 0
|
541
|
+
content_type.strip.split(/\s*;\s*/)[0].downcase
|
538
542
|
else
|
539
543
|
if block_given?
|
540
544
|
yield
|
@@ -630,7 +634,7 @@ module RMail
|
|
630
634
|
# Set the boundary parameter of this message's Content-Type:
|
631
635
|
# field.
|
632
636
|
def set_boundary(boundary)
|
633
|
-
params =
|
637
|
+
params = params('content-type')
|
634
638
|
params ||= {}
|
635
639
|
params['boundary'] = boundary
|
636
640
|
content_type = content_type()
|
@@ -889,7 +893,7 @@ module RMail
|
|
889
893
|
|
890
894
|
protected
|
891
895
|
|
892
|
-
|
896
|
+
attr_accessor :fields
|
893
897
|
|
894
898
|
private
|
895
899
|
|