Skip to content

Commit

Permalink
Fix broken spec for issue 453 and change documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikel Lindsaar authored and wktk committed May 27, 2016
1 parent 5ec84ae commit 6e12d7f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
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
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
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

0 comments on commit 6e12d7f

Please sign in to comment.