[DRE-commits] [ruby-mail] 02/07: Merge branch 'upstream'
Antonio Terceiro
terceiro at moszumanska.debian.org
Tue Sep 22 18:13:10 UTC 2015
This is an automated email from the git hooks/post-receive script.
terceiro pushed a commit to branch master
in repository ruby-mail.
commit 43b545a997fe99abf3264415182fd7aa1153450e
Merge: 99e652d 9b7b7dd
Author: Antonio Terceiro <terceiro at debian.org>
Date: Tue Sep 22 14:52:39 2015 -0300
Merge branch 'upstream'
.travis.yml | 20 +-
CHANGELOG.rdoc | 9 +-
README.md | 10 +-
lib/mail.rb | 5 +-
lib/mail/body.rb | 32 +-
lib/mail/{patterns.rb => constants.rb} | 26 +-
lib/mail/core_extensions/string.rb | 7 +-
lib/mail/elements/address.rb | 121 +-
lib/mail/elements/address_list.rb | 12 +-
lib/mail/encodings.rb | 37 +-
lib/mail/encodings/unix_to_unix.rb | 17 +
lib/mail/field.rb | 4 +-
lib/mail/field_list.rb | 2 +-
lib/mail/fields/common/common_field.rb | 3 +-
lib/mail/fields/common/parameter_hash.rb | 6 +-
lib/mail/fields/unstructured_field.rb | 6 +-
lib/mail/header.rb | 5 +-
lib/mail/mail.rb | 4 +-
lib/mail/matchers/has_sent_mail.rb | 4 +-
lib/mail/message.rb | 13 +-
lib/mail/parsers/content_type_parser.rb | 6 +-
lib/mail/parsers/ragel/common.rl | 3 +-
lib/mail/parsers/ragel/ruby.rb | 7 +-
.../ragel/ruby/machines/envelope_from_machine.rb | 2858 ++++++++++----------
lib/mail/utilities.rb | 6 +-
lib/mail/version.rb | 22 +-
lib/mail/version_specific/ruby_1_8.rb | 4 +-
lib/mail/version_specific/ruby_1_9.rb | 62 +-
mail.gemspec | 12 +-
...japanese_shiftjis.eml => japanese_iso_2022.eml} | 0
.../emails/multi_charset/japanese_shift_jis.eml | 15 +
spec/mail/attachments_list_spec.rb | 106 +-
spec/mail/body_spec.rb | 226 +-
spec/mail/configuration_spec.rb | 26 +-
spec/mail/core_extensions/string_spec.rb | 28 +-
spec/mail/core_extensions_spec.rb | 44 +-
spec/mail/elements/address_list_spec.rb | 52 +-
spec/mail/elements/address_spec.rb | 153 +-
spec/mail/elements/date_time_element_spec.rb | 6 +-
spec/mail/elements/envelope_from_element_spec.rb | 20 +-
spec/mail/elements/message_ids_element_spec.rb | 14 +-
spec/mail/elements/phrase_list_spec.rb | 6 +-
spec/mail/elements/received_element_spec.rb | 10 +-
spec/mail/encoding_spec.rb | 41 +-
spec/mail/encodings/base64_spec.rb | 8 +-
spec/mail/encodings/quoted_printable_spec.rb | 16 +-
spec/mail/encodings/unix_to_unix_spec.rb | 40 +
spec/mail/encodings_spec.rb | 309 ++-
spec/mail/example_emails_spec.rb | 184 +-
spec/mail/field_list_spec.rb | 12 +-
spec/mail/field_spec.rb | 144 +-
spec/mail/fields/bcc_field_spec.rb | 30 +-
spec/mail/fields/cc_field_spec.rb | 32 +-
spec/mail/fields/comments_field_spec.rb | 10 +-
spec/mail/fields/common/address_container_spec.rb | 8 +-
spec/mail/fields/common/common_address_spec.rb | 82 +-
spec/mail/fields/common/common_date_spec.rb | 6 +-
spec/mail/fields/common/common_field_spec.rb | 24 +-
spec/mail/fields/common/common_message_id_spec.rb | 8 +-
spec/mail/fields/common/parameter_hash_spec.rb | 36 +-
spec/mail/fields/content_description_field_spec.rb | 10 +-
spec/mail/fields/content_disposition_field_spec.rb | 38 +-
spec/mail/fields/content_id_field_spec.rb | 44 +-
spec/mail/fields/content_location_field_spec.rb | 16 +-
.../fields/content_transfer_encoding_field_spec.rb | 36 +-
spec/mail/fields/content_type_field_spec.rb | 484 ++--
spec/mail/fields/date_field_spec.rb | 32 +-
spec/mail/fields/envelope_spec.rb | 6 +-
spec/mail/fields/from_field_spec.rb | 40 +-
spec/mail/fields/in_reply_to_field_spec.rb | 34 +-
spec/mail/fields/keywords_field_spec.rb | 26 +-
spec/mail/fields/message_id_field_spec.rb | 46 +-
spec/mail/fields/mime_version_field_spec.rb | 34 +-
spec/mail/fields/received_field_spec.rb | 32 +-
spec/mail/fields/references_field_spec.rb | 32 +-
spec/mail/fields/reply_to_field_spec.rb | 28 +-
spec/mail/fields/resent_bcc_field_spec.rb | 28 +-
spec/mail/fields/resent_cc_field_spec.rb | 28 +-
spec/mail/fields/resent_date_field_spec.rb | 26 +-
spec/mail/fields/resent_from_field_spec.rb | 28 +-
spec/mail/fields/resent_message_id_field_spec.rb | 16 +-
spec/mail/fields/resent_sender_field_spec.rb | 20 +-
spec/mail/fields/resent_to_field_spec.rb | 28 +-
spec/mail/fields/return_path_field_spec.rb | 12 +-
spec/mail/fields/sender_field_spec.rb | 39 +-
spec/mail/fields/structured_field_spec.rb | 22 +-
spec/mail/fields/to_field_spec.rb | 40 +-
spec/mail/fields/unstructured_field_spec.rb | 66 +-
spec/mail/header_spec.rb | 275 +-
spec/mail/mail_spec.rb | 14 +-
spec/mail/message_spec.rb | 998 +++----
spec/mail/mime_messages_spec.rb | 228 +-
spec/mail/multibyte_spec.rb | 4 +-
spec/mail/multipart_report_spec.rb | 44 +-
spec/mail/network/delivery_methods/exim_spec.rb | 24 +-
.../network/delivery_methods/file_delivery_spec.rb | 40 +-
.../mail/network/delivery_methods/sendmail_spec.rb | 26 +-
.../delivery_methods/smtp_connection_spec.rb | 16 +-
spec/mail/network/delivery_methods/smtp_spec.rb | 48 +-
.../network/delivery_methods/test_mailer_spec.rb | 20 +-
spec/mail/network/retriever_methods/imap_spec.rb | 139 +-
spec/mail/network/retriever_methods/pop3_spec.rb | 100 +-
.../retriever_methods/test_retriever_spec.rb | 46 +-
spec/mail/network_spec.rb | 128 +-
spec/mail/parsers/address_lists_parser_spec.rb | 22 +-
.../content_transfer_encoding_parser_spec.rb | 28 +-
spec/mail/part_spec.rb | 60 +-
spec/mail/parts_list_spec.rb | 4 +-
spec/mail/round_tripping_spec.rb | 18 +-
spec/mail/utilities_spec.rb | 130 +-
.../mail/version_specific/escape_paren_1_8_spec.rb | 10 +-
spec/matchers/break_down_to.rb | 55 +-
spec/matchers_spec.rb | 80 +-
spec/spec_helper.rb | 15 +-
114 files changed, 4640 insertions(+), 4242 deletions(-)
diff --cc lib/mail/message.rb
index 9daa86b,5a4ece0..f7db708
--- a/lib/mail/message.rb
+++ b/lib/mail/message.rb
@@@ -1980,9 -1986,8 +1986,10 @@@ module Mai
end
def raw_source=(value)
+ value = value.dup.force_encoding(Encoding::BINARY) if RUBY_VERSION >= "1.9.1"
@raw_source = value.to_crlf
+ @raw_source.force_encoding("binary") if RUBY_VERSION >= "1.9.1"
+ @raw_source
end
# see comments to body=. We take data and process it lazily
diff --cc spec/mail/body_spec.rb
index e4c9b7a,3fc1261..e1c59e8
--- a/spec/mail/body_spec.rb
+++ b/spec/mail/body_spec.rb
@@@ -196,16 -224,16 +224,22 @@@ describe Mail::Body d
body.boundary = '------=_MIMEPART'
new_body = Mail::Body.new(body.encoded)
new_body.split!('------=_MIMEPART')
- new_body.parts.length.should eq 2
- new_body.preamble.should eq "this is some text"
+ expect(new_body.parts.length).to eq 2
+ expect(new_body.preamble).to eq "this is some text"
+ end
+
+ it "should split if boundary is not set" do
+ multipart_body = "\n\n--\nDate: Thu, 01 Aug 2013 15:14:20 +0100\nMime-Version: 1.0\nContent-Type: text/plain\nContent-Transfer-Encoding: 7bit\nContent-Disposition: attachment;\n filename=\"\"\nContent-ID: <51fa6d3cac796_d84e3fe5a58349e025683 at local.mail>\n\n\n\n----"
+ body = Mail::Body.new(multipart_body)
+ expect { body.split!(nil) }.not_to raise_error
end
+ it "should split if boundary is not set" do
+ multipart_body = "\n\n--\nDate: Thu, 01 Aug 2013 15:14:20 +0100\nMime-Version: 1.0\nContent-Type: text/plain\nContent-Transfer-Encoding: 7bit\nContent-Disposition: attachment;\n filename=\"\"\nContent-ID: <51fa6d3cac796_d84e3fe5a58349e025683 at local.mail>\n\n\n\n----"
+ body = Mail::Body.new(multipart_body)
+ doing { body.split!(nil) }.should_not raise_error
+ end
+
end
describe "detecting non ascii" do
diff --cc spec/mail/elements/address_spec.rb
index dcd1c80,fcd4b9e..9673e20
--- a/spec/mail/elements/address_spec.rb
+++ b/spec/mail/elements/address_spec.rb
@@@ -121,16 -121,16 +121,23 @@@ describe Mail::Address d
parse_text = "Mikel (first name) Lindsaar (author) <test at lindsaar.net>"
result = ['first name', 'author']
a = Mail::Address.new(parse_text)
- a.comments.should eq result
+ expect(a.comments).to eq result
+ end
+
+ it "should handle nested comments" do
+ parse_text = "bob at example.com (hello (nested) yeah)"
+ result = ["hello \(nested\) yeah"]
+ a = Mail::Address.new(parse_text)
+ expect(a.comments).to eq result
end
+ it "should handle nested comments" do
+ parse_text = "bob at example.com (hello (nested) yeah)"
+ result = ["hello \(nested\) yeah"]
+ a = Mail::Address.new(parse_text)
+ a.comments.should eq result
+ end
+
it "should give back the raw value" do
parse_text = "Mikel (first name) Lindsaar (author) <test at lindsaar.net>"
result = "Mikel (first name) Lindsaar (author) <test at lindsaar.net>"
diff --cc spec/mail/encodings_spec.rb
index 5ec0647,cbdf070..5bd061b
--- a/spec/mail/encodings_spec.rb
+++ b/spec/mail/encodings_spec.rb
@@@ -151,21 -151,25 +151,37 @@@ describe Mail::Encodings d
it "should decode a string that looks similar to an encoded string (contains '=?')" do
string = "1+1=?"
- Mail::Encodings.value_decode(string).should == string
+ expect(Mail::Encodings.value_decode(string)).to eq(string)
+ end
+
+ it "should collapse adjacent words" do
+ string = "=?utf-8?B?0L3QvtCy0YvQuSDRgdC+0YLRgNGD0LTQvdC40Log4oCUINC00L7RgNC+0YQ=?=\n =?utf-8?B?0LXQtdCy?="
+ result = "новый сотрудник — дорофеев"
+ expect(Mail::Encodings.value_decode(string)).to eq(result)
+ end
+
+ it "should parse adjacent words with no space" do
+ string = "=?utf-8?B?0L3QvtCy0YvQuSDRgdC+0YLRgNGD0LTQvdC40Log4oCUINC00L7RgNC+0YQ=?==?utf-8?B?0LXQtdCy?="
+ result = "новый сотрудник — дорофеев"
+ expect(Mail::Encodings.value_decode(string)).to eq(result)
+ end
+
+ it "should decode a blank string" do
+ expect(Mail::Encodings.value_decode("=?utf-8?B??=")).to eq ""
end
+ it "should collapse adjacent words" do
+ string = "=?utf-8?B?0L3QvtCy0YvQuSDRgdC+0YLRgNGD0LTQvdC40Log4oCUINC00L7RgNC+0YQ=?=\n =?utf-8?B?0LXQtdCy?="
+ result = "новый сотрудник — дорофеев"
+ Mail::Encodings.value_decode(string).should == result
+ end
+
+ it "should parse adjacent words with no space" do
+ string = "=?utf-8?B?0L3QvtCy0YvQuSDRgdC+0YLRgNGD0LTQvdC40Log4oCUINC00L7RgNC+0YQ=?==?utf-8?B?0LXQtdCy?="
+ result = "новый сотрудник — дорофеев"
+ Mail::Encodings.value_decode(string).should == result
+ end
+
if '1.9'.respond_to?(:force_encoding)
it "should decode 8bit encoded string" do
string = "=?8bit?Q?ALPH=C3=89E?="
@@@ -642,14 -645,14 +657,19 @@@
a = "=?WINDOWS-1252?Q?simple_=96_dash_=96_?="
b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8')
- b.should eq "simple – dash – "
+ expect(b).to eq "simple – dash – "
+ end
+
+ it "should recognize iso646-us" do
+ decoded = Mail::Encodings.value_decode "[kj] =?ISO646-US?Q?Re:_[kj]_[KJ]_Money_is_not_our_god_should_?=\r\n =?ISO646-US?Q?be_played_on_US_Tour...+_Elys=3Fe_Montmartre?="
+ expect(decoded).to eq("[kj] Re: [kj] [KJ] Money is not our god should be played on US Tour...+ Elys?e Montmartre")
end
+ it "should recognize iso646-us" do
+ decoded = Mail::Encodings.value_decode "[kj] =?ISO646-US?Q?Re:_[kj]_[KJ]_Money_is_not_our_god_should_?=\r\n =?ISO646-US?Q?be_played_on_US_Tour...+_Elys=3Fe_Montmartre?="
+ decoded.should == "[kj] Re: [kj] [KJ] Money is not our god should be played on US Tour...+ Elys?e Montmartre"
+ end
+
it "should unquote multiple strings in the middle of the text" do
a = "=?Shift_JIS?Q?=93=FA=96{=8C=EA=?= <a at example.com>, =?Shift_JIS?Q?=93=FA=96{=8C=EA=?= <b at example.com>"
b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8')
@@@ -665,15 -668,15 +685,21 @@@
it "should handle quoted string with mixed content that have a plain string at the end" do
a = 'Der Kunde ist K=?utf-8?B?w7Y=?=nig'
b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8')
- b.should eq "Der Kunde ist König"
+ expect(b).to eq "Der Kunde ist König"
+ end
+
+ it "should handle utf_8" do
+ a = 'Der Kunde ist K=?utf_8?B?w7Y=?=nig'
+ b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8')
+ expect(b).to eq "Der Kunde ist König"
end
+ it "should handle utf_8" do
+ a = 'Der Kunde ist K=?utf_8?B?w7Y=?=nig'
+ b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8')
+ b.should eq "Der Kunde ist König"
+ end
+
end
end
diff --cc spec/mail/fields/content_type_field_spec.rb
index 276a6b7,35e9fcb..0a86abc
--- a/spec/mail/fields/content_type_field_spec.rb
+++ b/spec/mail/fields/content_type_field_spec.rb
@@@ -738,10 -738,9 +738,10 @@@ describe Mail::ContentTypeField d
end
it "should just ignore illegal params like audio/x-midi;\r\n\sname=Part .exe" do
+ pending "fixed in pr #481"
c = Mail::ContentTypeField.new("audio/x-midi;\r\n\sname=Part .exe")
- c.string.should eq 'audio/x-midi'
- c.parameters['name'].should eq nil
+ expect(c.string).to eq 'audio/x-midi'
+ expect(c.parameters['name']).to eq nil
end
it "should handle: rfc822; format=flowed; charset=iso-8859-15" do
diff --cc spec/mail/header_spec.rb
index 52d00d5,6ef7b00..c331c51
--- a/spec/mail/header_spec.rb
+++ b/spec/mail/header_spec.rb
@@@ -61,14 -61,14 +72,20 @@@ describe Mail::Header d
it "should know its own charset if set" do
header = Mail::Header.new
header['content-type'] = 'text/plain; charset=utf-8'
- header.charset.should eq 'utf-8'
+ expect(header.charset).to eq 'utf-8'
+ end
+
+ it "should not unset previously set charset if content-type is set without charset" do
+ header = Mail::Header.new(nil, 'utf-8')
+ header['content-type'] = 'text/plain'
+ expect(header.charset).to eq 'utf-8'
end
+
+ it "should not unset previously set charset if content-type is set without charset" do
+ header = Mail::Header.new(nil, 'utf-8')
+ header['content-type'] = 'text/plain'
+ header.charset.should eq 'utf-8'
+ end
it "shouldn't die when queried for a charset and the content-type header is invalid" do
header = Mail::Header.new
diff --cc spec/mail/message_spec.rb
index 4030141,53d8c15..6d9b709
--- a/spec/mail/message_spec.rb
+++ b/spec/mail/message_spec.rb
@@@ -1704,21 -1735,21 +1744,33 @@@ describe Mail::Message d
InterceptorAgent.intercept = true
mail.deliver
InterceptorAgent.intercept = false
- mail.to.should eq ['bob at example.com']
+ expect(mail.to).to eq ['bob at example.com']
+ end
+
+ it "should allow interceptors to be unregistered" do
+ mail = Mail.new(:from => 'bob at example.com', :to => 'bobette at example.com')
+ mail.to = 'fred at example.com'
+ mail.delivery_method :test
+ Mail.register_interceptor(InterceptorAgent)
+ InterceptorAgent.intercept = true
+ Mail.unregister_interceptor(InterceptorAgent)
+ mail.deliver
+ InterceptorAgent.intercept = false
+ expect(mail.to).to eq ['fred at example.com']
end
+ it "should allow interceptors to be unregistered" do
+ mail = Mail.new(:from => 'bob at example.com', :to => 'bobette at example.com')
+ mail.to = 'fred at example.com'
+ mail.delivery_method :test
+ Mail.register_interceptor(InterceptorAgent)
+ InterceptorAgent.intercept = true
+ Mail.unregister_interceptor(InterceptorAgent)
+ mail.deliver
+ InterceptorAgent.intercept = false
+ mail.to.should eq ['fred at example.com']
+ end
+
end
describe "error handling" do
diff --cc spec/mail/network/retriever_methods/imap_spec.rb
index c06a3f7,720264d..f6b93d2
--- a/spec/mail/network/retriever_methods/imap_spec.rb
+++ b/spec/mail/network/retriever_methods/imap_spec.rb
@@@ -78,13 -78,13 +78,18 @@@ describe "IMAP Retriever" d
it "should handle the :mailbox option" do
Mail.find(:mailbox => 'SOME-RANDOM-MAILBOX')
- MockIMAP.mailbox.should eq 'SOME-RANDOM-MAILBOX'
+ expect(MockIMAP.mailbox).to eq 'SOME-RANDOM-MAILBOX'
+ end
+ it "should handle the :uid option" do
+ messages = Mail.find(:uid => 1)
+
+ expect(messages[0].raw_source).to eq MockIMAP.examples.map { |m| m.attr['RFC822'] }[1]
end
+ it "should handle the :uid option" do
+ messages = Mail.find(:uid => 1)
+
+ messages[0].raw_source.should eq MockIMAP.examples.map { |m| m.attr['RFC822'] }[1]
+ end
it "should find the last 10 messages by default" do
messages = Mail.find
diff --cc spec/mail/parsers/address_lists_parser_spec.rb
index c5be6d6,8693da1..802dd56
--- a/spec/mail/parsers/address_lists_parser_spec.rb
+++ b/spec/mail/parsers/address_lists_parser_spec.rb
@@@ -11,24 -11,24 +11,42 @@@ describe "AddressListsParser" d
it "should parse an address list separated by semicolons" do
text = 'Mikel Lindsaar <test at lindsaar.net>; Friends: test2 at lindsaar.net; Ada <test3 at lindsaar.net>;'
a = Mail::Parsers::AddressListsParser.new
- a.parse(text).should_not be_nil
+ expect(a.parse(text)).not_to be_nil
+ end
+
+ context "parsing an address with a space at the end" do
+ it "only finds a single address" do
+ text = 'Mikel Lindsaar <test at lindsaar.net> '
+ a = Mail::Parsers::AddressListsParser.new
+ expect(a.parse(text).addresses.size).to eq 1
+ end
+ end
+
+ context "parsing an address which begins with a comment" do
+ it "extracts local string correctly" do
+ text = '(xxxx xxxxxx xxxx)ababab at example.com'
+
+ a = Mail::Parsers::AddressListsParser.new
+ expect(a.parse(text).addresses.size).to eq 1
+ expect(a.parse(text).addresses.first.local).to eq 'ababab'
+ end
end
+
+ context "parsing an address with a space at the end" do
+ it "only finds a single address" do
+ text = 'Mikel Lindsaar <test at lindsaar.net> '
+ a = Mail::Parsers::AddressListsParser.new
+ a.parse(text).addresses.size.should eq 1
+ end
+ end
+
+ context "parsing an address which begins with a comment" do
+ it "extracts local string correctly" do
+ text = '(xxxx xxxxxx xxxx)ababab at example.com'
+
+ a = Mail::Parsers::AddressListsParser.new
+ a.parse(text).addresses.size.should eq 1
+ a.parse(text).addresses.first.local.should eq 'ababab'
+ end
+ end
end
diff --cc spec/matchers_spec.rb
index d100308,bbff4a1..10a9871
--- a/spec/matchers_spec.rb
+++ b/spec/matchers_spec.rb
@@@ -73,35 -103,9 +103,35 @@@ describe "have_sent_email" d
end
end
+ context "with #cc" do
+ context "and a matching recipient" do
+ it { should have_sent_email.cc('mom at example.com') }
+ it { should have_sent_email.cc('dad at example.com') }
+ it { should have_sent_email.cc('mom at example.com').cc('dad at example.com') }
+ it { should have_sent_email.cc(['mom at example.com', 'dad at example.com']) }
+ end
+
+ context "and a non-matching recipient" do
+ it { should_not have_sent_email.cc('granny at example.com') }
+ end
+ end
+
+ context "with #bcc" do
+ context "and a matching recipient" do
+ it { should have_sent_email.bcc('alice at example.com') }
+ it { should have_sent_email.bcc('sue at example.com') }
+ it { should have_sent_email.bcc('alice at example.com').bcc('sue at example.com') }
+ it { should have_sent_email.bcc(['alice at example.com', 'sue at example.com']) }
+ end
+
+ context "and a non-matching recipient" do
+ it { should_not have_sent_email.bcc('mario at example.com') }
+ end
+ end
+
context "with #subject" do
context "and a matching subject" do
- it { should have_sent_email.with_subject('The facts you requested') }
+ it { is_expected.to have_sent_email.with_subject('The facts you requested') }
end
context "and a non-matching subject" do
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-mail.git
More information about the Pkg-ruby-extras-commits
mailing list