Skip to content

Commit

Permalink
Encodings.value_decode(str): Treat lines with mixed encoding correctl…
Browse files Browse the repository at this point in the history
…y when the line ends with a plain text part.

Fixes mikel#338
  • Loading branch information
janv committed Jan 28, 2012
1 parent f856208 commit cb1df03
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mail/encodings.rb
Expand Up @@ -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'
Expand Down
6 changes: 6 additions & 0 deletions spec/mail/encodings_spec.rb
Expand Up @@ -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

Expand Down

0 comments on commit cb1df03

Please sign in to comment.