Permalink
Browse files

Fix broken spec for issue 453 and change documentation

  • Loading branch information...
1 parent bb25038 commit f8da70c9e4fd7a5414e1794410c1521418f745e1 @mikel committed Nov 17, 2012
Showing with 12 additions and 9 deletions.
  1. +1 −0 CHANGELOG.rdoc
  2. +4 −1 lib/mail/version_specific/ruby_1_8.rb
  3. +1 −1 lib/mail/version_specific/ruby_1_9.rb
  4. +6 −7 spec/mail/encodings_spec.rb
View
@@ -1,5 +1,6 @@
== HEAD
+* Fix failing spec Issue 453 on Ruby 1.9.3
* Fix mail reading: don't raise invalid byte sequence in UTF-8 when reading non-UTF-8 emails (mreinsch)
* See #353 define NilClass#blank? only if not defined yet
* Fixes #349 an inverted condition on imap open read_only
@@ -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
@@ -69,7 +69,7 @@ def Ruby19.q_value_decode(str)
if match
encoding = match[1]
string = match[2].gsub(/_/, '=20')
- # Remove trailing = if it exists in a Q encoding as Ruby 1.9.3 does not silently discard
+ # Remove trailing = if it exists in a Q encoding
string = string.sub(/\=$/, '')
str = Encodings::QuotedPrintable.decode(string)
str.force_encoding(fix_encoding(encoding))
@@ -216,13 +216,6 @@
end
end
- it "should decode JIS with Q decoding" do
- string = "=?Shift_JIS?Q?=93=FA=96{=8C=EA=?="
- result = "日本語"
- result.force_encoding('UTF-8') if RUBY_VERSION >= '1.9'
- Mail::Encodings.q_value_decode(string).should eq result
- end
-
it "should decode an encoded string" do
string = '=?UTF-8?Q?This_is_=E3=81=82_string?='
result = "This is あ string"
@@ -617,6 +610,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=?= <a@example.com>, =?Shift_JIS?Q?=93=FA=96{=8C=EA=?= <b@example.com>"
b = Mail::Encodings.unquote_and_convert_to(a, 'utf-8')

0 comments on commit f8da70c

Please sign in to comment.