aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfrancis <francis>2008-03-06 22:41:28 +0000
committerfrancis <francis>2008-03-06 22:41:28 +0000
commited432a31046257ff38b9b3ffabb91717fa24eb9b (patch)
tree40e4986b135f84e8d8265a8b4c16b1c32171fb27
parent0792a9431f33a47860a3debcdf828f149d291e60 (diff)
PDFs often seem to not have right mime type - use heuristic based on filename to detect this.
-rw-r--r--app/models/incoming_message.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index 20f7ac7e4..58a6ec25b 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -18,7 +18,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.50 2008-03-06 20:10:29 francis Exp $
+# $Id: incoming_message.rb,v 1.51 2008-03-06 22:41:28 francis Exp $
# TODO
@@ -182,6 +182,13 @@ class IncomingMessage < ActiveRecord::Base
end
end
else
+ # PDFs often come with this mime type, fix it up for view code
+ if curr_mail.content_type == 'application/octet-stream'
+ if TMail::Mail.get_part_file_name(curr_mail).match(/\.pdf$/)
+ curr_mail.content_type = 'application/pdf'
+ end
+ end
+ # Store leaf
leaves_so_far += [curr_mail]
end
return leaves_so_far