aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/incoming_message.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index 8aaaa66e6..3abf38f3f 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -17,7 +17,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.74 2008-04-14 15:45:01 francis Exp $
+# $Id: incoming_message.rb,v 1.75 2008-04-14 23:12:36 francis Exp $
# TODO
@@ -433,6 +433,18 @@ class IncomingMessage < ActiveRecord::Base
text += File.read(tempfile.path + ".txt") + "\n\n"
File.unlink(tempfile.path + ".txt")
tempfile.close
+ elsif attachment.content_type == 'application/msexcel'
+ # Bit crazy using catdoc - but xls2csv, xlhtml and py_xls2txt
+ # only extract text from cells, not from floating notes. catdoc
+ # may be fooled by weird character sets, but will probably do for
+ # UK FOI requests.
+ tempfile = Tempfile.new('foixls')
+ tempfile.print attachment.body
+ tempfile.flush
+ IO.popen("/usr/bin/catdoc " + tempfile.path, "r") do |child|
+ text += child.read() + "\n\n"
+ end
+ tempfile.close
elsif attachment.content_type == 'application/pdf'
tempfile = Tempfile.new('foipdf')
tempfile.print attachment.body