Skip to content

Fix the branch 2-4-stable has errors and failure in spec #958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.rdoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
== HEAD

* Fix failing spec Issue 453 on Ruby 1.9.3

== Version 2.4.4 - Wed Mar 14 22:44:00 +1100 2012 Mikel Lindsaar <[email protected]>

* Fix security vulnerability allowing command line exploit when using file delivery method
Expand Down
9 changes: 6 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
source :rubygems

gem "activesupport", ">= 2.3.6"
gem 'activesupport', '>= 2.3.6' if RUBY_VERSION >= '1.9.3'
gem 'activesupport', '>= 2.3.6', '< 4.0.0' if RUBY_VERSION < '1.9.3'
gem "tlsmail" if RUBY_VERSION <= '1.8.6'
gem "mime-types", "~> 1.16"
gem "treetop", "~> 1.4.10"
gem "i18n", ">= 0.4.0"
gem 'i18n', '>= 0.4.0' if RUBY_VERSION >= '1.9.3'
gem 'i18n', '>= 0.4.0', '< 0.7.0' if RUBY_VERSION < '1.9.3'

if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
gem 'jruby-openssl'
end

group :test do
gem "rake", "> 0.8.7"
gem 'rake', '> 0.8.7' if RUBY_VERSION >= '1.9.3'
gem 'rake', '> 0.8.7', '< 11.0.1' if RUBY_VERSION < '1.9.3'
gem "rspec", "~> 2.8.0"
case
when defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
Expand Down
5 changes: 4 additions & 1 deletion lib/mail/version_specific/ruby_1_8.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ def Ruby18.q_value_decode(str)
match = str.match(/\=\?(.+)?\?[Qq]\?(.+)?\?\=/m)
if match
encoding = match[1]
str = Encodings::QuotedPrintable.decode(match[2].gsub(/_/, '=20'))
string = match[2].gsub(/_/, '=20')
# Remove trailing = if it exists in a Q encoding
string = string.sub(/\=$/, '')
str = Encodings::QuotedPrintable.decode(string)
end
str
end
Expand Down
5 changes: 4 additions & 1 deletion lib/mail/version_specific/ruby_1_9.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ def Ruby19.q_value_decode(str)
match = str.match(/\=\?(.+)?\?[Qq]\?(.+)?\?\=/m)
if match
encoding = match[1]
str = Encodings::QuotedPrintable.decode(match[2].gsub(/_/, '=20'))
string = match[2].gsub(/_/, '=20')
# Remove trailing = if it exists in a Q encoding
string = string.sub(/\=$/, '')
str = Encodings::QuotedPrintable.decode(string)
str.force_encoding(fix_encoding(encoding))
end
decoded = str.encode("utf-8", :invalid => :replace, :replace => "")
Expand Down
3 changes: 2 additions & 1 deletion mail.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ Gem::Specification.new do |s|

s.add_dependency('mime-types', "~> 1.16")
s.add_dependency('treetop', '~> 1.4.8')
s.add_dependency('i18n', '>= 0.4.0')
s.add_dependency('i18n', '>= 0.4.0') if RUBY_VERSION >= '1.9.3'
s.add_dependency('i18n', '>= 0.4.0', '< 0.7.0') if RUBY_VERSION < '1.9.3'
s.add_dependency('jruby-openssl') if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
s.add_dependency('tlsmail', '~> 0.0.1') if RUBY_VERSION == '1.8.6'

Expand Down
6 changes: 6 additions & 0 deletions spec/mail/encodings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,12 @@
b.should eq expected
end

it "should unquote Shift_JIS QP with trailing =" do
a = "=?Shift_JIS?Q?=93=FA=96{=8C=EA=?="
b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8')
b.should eq "日本語"
end

it "should unquote multiple strings in the middle of the text" do
a = "=?Shift_JIS?Q?=93=FA=96{=8C=EA=?= <[email protected]>, =?Shift_JIS?Q?=93=FA=96{=8C=EA=?= <[email protected]>"
b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8')
Expand Down
4 changes: 4 additions & 0 deletions spec/mail/message_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ def basic_email

describe "YAML serialization" do
before(:each) do
# Ensure specs don't randomly fail due to messages being generated 1 second apart
time = DateTime.now
DateTime.stub(:now).and_return(time)

@yaml_mail = Mail::Message.new(:to => '[email protected]',
:cc => '[email protected]',
:bcc => '[email protected]',
Expand Down