aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/incoming_message.rb8
-rw-r--r--spec/models/incoming_message_spec.rb13
2 files changed, 19 insertions, 2 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index e229268b3..fb687506a 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -19,7 +19,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: incoming_message.rb,v 1.206 2009-06-26 14:28:37 francis Exp $
+# $Id: incoming_message.rb,v 1.207 2009-07-09 18:36:50 louise Exp $
# TODO
# Move some of the (e.g. quoting) functions here into rblib, as they feel
@@ -1017,7 +1017,11 @@ class IncomingMessage < ActiveRecord::Base
for entry in zip_file
if entry.file?
filename = entry.to_s
- body = entry.get_input_stream.read
+ begin
+ body = entry.get_input_stream.read
+ rescue
+ next
+ end
calc_mime = filename_to_mimetype(filename)
if calc_mime
content_type = calc_mime
diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb
index f3bb51480..306d08439 100644
--- a/spec/models/incoming_message_spec.rb
+++ b/spec/models/incoming_message_spec.rb
@@ -18,6 +18,19 @@ describe IncomingMessage, " when dealing with incoming mail" do
end
+
+describe IncomingMessage, "when getting the attachment text" do
+
+ it "should not raise an error if the expansion of a zip file raises an error" do
+ mock_entry = mock('ZipFile entry', :file? => true)
+ mock_entry.stub!(:get_input_stream).and_raise("invalid distance too far back")
+ Zip::ZipFile.stub!(:open).and_return([mock_entry])
+ IncomingMessage.get_attachment_text_internal_one_file('application/zip', "some string")
+ end
+
+end
+
+
describe IncomingMessage, " display attachments" do
it "should not show slashes in filenames" do