Skip to content

Commit 6e12d7f

Browse files
Mikel Lindsaarwktk
authored andcommitted
Fix broken spec for issue 453 and change documentation
1 parent 5ec84ae commit 6e12d7f

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

CHANGELOG.rdoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
== HEAD
22

3+
* Fix failing spec Issue 453 on Ruby 1.9.3
4+
35
== Version 2.4.4 - Wed Mar 14 22:44:00 +1100 2012 Mikel Lindsaar <mikel@reinteractive.net>
46

57
* Fix security vulnerability allowing command line exploit when using file delivery method

lib/mail/version_specific/ruby_1_8.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ def Ruby18.q_value_decode(str)
8080
match = str.match(/\=\?(.+)?\?[Qq]\?(.+)?\?\=/m)
8181
if match
8282
encoding = match[1]
83-
str = Encodings::QuotedPrintable.decode(match[2].gsub(/_/, '=20'))
83+
string = match[2].gsub(/_/, '=20')
84+
# Remove trailing = if it exists in a Q encoding
85+
string = string.sub(/\=$/, '')
86+
str = Encodings::QuotedPrintable.decode(string)
8487
end
8588
str
8689
end

lib/mail/version_specific/ruby_1_9.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ def Ruby19.q_value_decode(str)
6868
match = str.match(/\=\?(.+)?\?[Qq]\?(.+)?\?\=/m)
6969
if match
7070
encoding = match[1]
71-
str = Encodings::QuotedPrintable.decode(match[2].gsub(/_/, '=20'))
71+
string = match[2].gsub(/_/, '=20')
72+
# Remove trailing = if it exists in a Q encoding
73+
string = string.sub(/\=$/, '')
74+
str = Encodings::QuotedPrintable.decode(string)
7275
str.force_encoding(fix_encoding(encoding))
7376
end
7477
decoded = str.encode("utf-8", :invalid => :replace, :replace => "")

spec/mail/encodings_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,12 @@
609609
b.should eq expected
610610
end
611611

612+
it "should unquote Shift_JIS QP with trailing =" do
613+
a = "=?Shift_JIS?Q?=93=FA=96{=8C=EA=?="
614+
b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8')
615+
b.should eq "日本語"
616+
end
617+
612618
it "should unquote multiple strings in the middle of the text" do
613619
a = "=?Shift_JIS?Q?=93=FA=96{=8C=EA=?= <a@example.com>, =?Shift_JIS?Q?=93=FA=96{=8C=EA=?= <b@example.com>"
614620
b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8')

0 commit comments

Comments
 (0)