Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Collapse adjacent =??B? words losslessly

Before this change the code assumed you could concatenate two Base64
strings, which is not true.

This fix relies on non-standard behaviour of our parser: RFC 2047 says
that encoded-words MUST be separated by at least a space, but we happily
parse two unseparated encoded-words.

Fixes: #560
Fixes: #561
Broken-since: 2.5.4 (cb81621)
  • Loading branch information...
commit b832faf6d05f85422dd921d3b97ed842436f22a8 1 parent 9f01ba9
@ConradIrwin ConradIrwin authored
Showing with 6 additions and 1 deletion.
  1. +0 −1  lib/mail/encodings.rb
  2. +6 −0 spec/mail/encodings_spec.rb
View
1  lib/mail/encodings.rb
@@ -292,7 +292,6 @@ def Encodings.collapse_adjacent_encodings(str)
if encoding == previous_encoding
line = results.pop + line
- line.gsub!(/\?\=\=\?.+?\?[QqBb]\?/m, '')
end
previous_encoding = encoding
View
6 spec/mail/encodings_spec.rb
@@ -154,6 +154,12 @@
Mail::Encodings.value_decode(string).should == string
end
+ it "should collapse adjacent words" do
+ string = "=?utf-8?B?0L3QvtCy0YvQuSDRgdC+0YLRgNGD0LTQvdC40Log4oCUINC00L7RgNC+0YQ=?=\n =?utf-8?B?0LXQtdCy?="
+ result = "новый сотрудник — дорофеев"
+ Mail::Encodings.value_decode(string).should == result
+ end
+
if '1.9'.respond_to?(:force_encoding)
it "should decode 8bit encoded string" do
string = "=?8bit?Q?ALPH=C3=89E?="
Please sign in to comment.
Something went wrong with that request. Please try again.