aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/mail_handler/backends/mail_extensions.rb9
-rw-r--r--spec/lib/mail_handler/mail_handler_spec.rb7
2 files changed, 16 insertions, 0 deletions
diff --git a/lib/mail_handler/backends/mail_extensions.rb b/lib/mail_handler/backends/mail_extensions.rb
index a5b6bc97e..029331802 100644
--- a/lib/mail_handler/backends/mail_extensions.rb
+++ b/lib/mail_handler/backends/mail_extensions.rb
@@ -46,6 +46,15 @@ module Mail
self
end
+
+ def set_envelope_header
+ raw_string = raw_source.to_s
+ if match_data = raw_source.to_s.match(/\AFrom\s(#{TEXT}+)#{CRLF}/m)
+ set_envelope(match_data[1])
+ self.raw_source = raw_string.sub(match_data[0], "")
+ end
+ end
+
end
# A patched version of the parameter hash that handles nil values without throwing
diff --git a/spec/lib/mail_handler/mail_handler_spec.rb b/spec/lib/mail_handler/mail_handler_spec.rb
index 241ce06c1..aa351bd94 100644
--- a/spec/lib/mail_handler/mail_handler_spec.rb
+++ b/spec/lib/mail_handler/mail_handler_spec.rb
@@ -9,6 +9,13 @@ end
describe 'when creating a mail object from raw data' do
+ it "should be able to parse a large email without raising an exception", :focus => true do
+ m = Mail.new
+ m.add_file(:filename => "attachment.data", :content => "a" * (8 * 1024 * 1024))
+ raw_email = "From jamis_buck@byu.edu Mon May 2 16:07:05 2005\r\n#{m.to_s}"
+ lambda { Mail::Message.new(raw_email) }.should_not raise_error
+ end
+
it 'should correctly parse a multipart email with a linebreak in the boundary' do
mail = get_fixture_mail('space-boundary.email')
mail.parts.size.should == 2