diff options
author | francis <francis> | 2008-03-15 03:26:05 +0000 |
---|---|---|
committer | francis <francis> | 2008-03-15 03:26:05 +0000 |
commit | 05a6f1f8dd9f97e6ade877afc6b7f59a9e8d9dd3 (patch) | |
tree | 8cf037ce51bed10dc72a6868b803143c39b99735 | |
parent | 43fef671517050616fbb1ae16e1719dc41b169e8 (diff) |
Use tempfile
-rw-r--r-- | app/models/incoming_message.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 465d51dca..88b988dc0 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.62 2008-03-15 03:20:23 francis Exp $ +# $Id: incoming_message.rb,v 1.63 2008-03-15 03:26:05 francis Exp $ # TODO @@ -298,11 +298,13 @@ class IncomingMessage < ActiveRecord::Base for uu in uus # Decode the string content = nil - IO.popen("/usr/bin/uudecode -o -", "r+") do |child| - child.write(uu) - child.close_write + tempfile = Tempfile.new('foiuu') + tempfile.print uu + tempfile.flush + IO.popen("/usr/bin/uudecode " + tempfile.path + " -o -", "r") do |child| content = child.read() end + tempfile.close # Make attachment type from it, working out filename and mime type attachment = FOIAttachment.new() attachment.body = content @@ -398,7 +400,7 @@ class IncomingMessage < ActiveRecord::Base if attachment.content_type == 'text/plain' text += attachment.body + "\n\n" elsif attachment.content_type == 'application/msword' - tempfile = Tempfile.new('foipdf') + tempfile = Tempfile.new('foidoc') tempfile.print attachment.body tempfile.flush system("/usr/bin/wvText " + tempfile.path + " " + tempfile.path + ".txt") |