aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/mail_handler/backends/mail_extensions.rb6
-rw-r--r--spec/lib/mail_handler/mail_handler_spec.rb5
2 files changed, 11 insertions, 0 deletions
diff --git a/lib/mail_handler/backends/mail_extensions.rb b/lib/mail_handler/backends/mail_extensions.rb
index 87af526bf..a277f540d 100644
--- a/lib/mail_handler/backends/mail_extensions.rb
+++ b/lib/mail_handler/backends/mail_extensions.rb
@@ -9,6 +9,12 @@ module Mail
attr_accessor :count_first_uudecode_count
end
+ class Part < Message
+ def inline?
+ header[:content_disposition].disposition_type == 'inline' if header[:content_disposition] rescue false
+ end
+ end
+
# A patched version of the parameter hash that handles nil values without throwing
# an error.
class ParameterHash < IndifferentHash
diff --git a/spec/lib/mail_handler/mail_handler_spec.rb b/spec/lib/mail_handler/mail_handler_spec.rb
index 49a65dade..ffc40ced9 100644
--- a/spec/lib/mail_handler/mail_handler_spec.rb
+++ b/spec/lib/mail_handler/mail_handler_spec.rb
@@ -22,6 +22,11 @@ describe 'when creating a mail object from raw data' do
mail.multipart?.should == true
end
+ it "should not fail on invalid byte sequence in content-disposition header", :focus => true do
+ part = Mail::Part.new("Content-Disposition: inline; filename=a\xB8z\r\n\r\nThis is the body text.")
+ lambda { part.inline? }.should_not raise_error
+ end
+
it 'should parse multiple to addresses with unqoted display names' do
mail = get_fixture_mail('multiple-unquoted-display-names.email')
mail.to.should == ["request-66666-caa77777@whatdotheyknow.com", "foi@example.com"]