Skip to content
Browse files

Encodings.value_decode(str): Treat lines with mixed encoding correctl…

…y when the line ends with a plain text part.

Fixes mikel/mail#338
  • Loading branch information...
1 parent f856208 commit cb1df03c64a88f78a1c45630f5e8d69fe7f2ccea @janv janv committed
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/mail/encodings.rb
  2. +6 −0 spec/mail/encodings_spec.rb
View
2 lib/mail/encodings.rb
@@ -130,7 +130,7 @@ def Encodings.value_decode(str)
text.scan(/( # Group around entire regex to include it in matches
\=\?[^?]+\?([QB])\?[^?]+?\?\= # Quoted String with subgroup for encoding method
| # or
- .+?(?=\=\?) # Plain String
+ .+?(?=\=\?|$) # Plain String
)/xmi).map do |matches|
string, method = *matches
if method == 'b' || method == 'B'
View
6 spec/mail/encodings_spec.rb
@@ -621,6 +621,12 @@
b.should eq "瑞庵2→最近門松を飾る家がほとんど見当たらない!寂しいことですね。日本のいいところ、わびさびの世界が失われつつある現在、なんとか後世に残さねば、勿体ない!とままは思うのだ。"
end
+ 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"
+ end
+
end
end

0 comments on commit cb1df03

Please sign in to comment.
Something went wrong with that request. Please try again.