aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfrancis <francis>2008-11-10 18:18:30 +0000
committerfrancis <francis>2008-11-10 18:18:30 +0000
commit405cd94fb7995e307cb74aa1b75055a95155a7c6 (patch)
treef5695c70553c82d8450186012ebc67b56f76e1c5
parent8880863dd52593633494aee20e289fe0bbd9c6a1 (diff)
Use proper conversion function for HTML main parts.
-rw-r--r--app/models/incoming_message.rb14
1 files changed, 4 insertions, 10 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index fcd80857e..7fc8a640d 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.166 2008-11-10 18:08:30 francis Exp $
+# $Id: incoming_message.rb,v 1.167 2008-11-10 18:18:30 francis Exp $
# TODO
# Move some of the (e.g. quoting) functions here into rblib, as they feel
@@ -608,14 +608,8 @@ class IncomingMessage < ActiveRecord::Base
text = main_part.body
text_charset = main_part.charset
if main_part.content_type == 'text/html'
- # XXX could use better HTML to text conversion than this!
- # (it only matters for emails without a text part, so not a massive deal
- # e.g. http://www.whatdotheyknow.com/request/35/response/177 )
- text.gsub!(/<br[^>]+>/, "\n")
- text.gsub!(/<p[^>]+>/, "\n\n")
- text.gsub!(/<div[^>]+>/, "\n\n")
- text.gsub!(/<\/?[^>]*>/, "")
- text = HTMLEntities.decode_entities(text)
+ # e.g. http://www.whatdotheyknow.com/request/35/response/177
+ text = IncomingMessage.get_attachment_text_internal_one_file(main_part.content_type, text)
end
end
@@ -864,7 +858,7 @@ class IncomingMessage < ActiveRecord::Base
text += child.read() + "\n\n"
end
elsif content_type == 'text/html'
- IO.popen("/usr/bin/lynx -force_html -dump " + tempfile.path, "r") do |child|
+ IO.popen("/usr/bin/lynx -display_charset=UTF-8 -force_html -dump " + tempfile.path, "r") do |child|
text += child.read() + "\n\n"
end
elsif content_type == 'application/vnd.ms-excel'