aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/incoming_message.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/incoming_message.rb')
-rw-r--r--app/models/incoming_message.rb12
1 files changed, 5 insertions, 7 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index f3844a153..367909f57 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -27,8 +27,6 @@
#
# 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.228 2009-10-21 11:24:14 francis Exp $
# TODO
# Move some of the (e.g. quoting) functions here into rblib, as they feel
@@ -77,8 +75,7 @@ class IncomingMessage < ActiveRecord::Base
# Documentation at http://i.loveruby.net/en/projects/tmail/doc/
def mail(force = nil)
if (!force.nil? || @mail.nil?) && !self.raw_email.nil?
- # Hack round bug in TMail's MIME decoding. Example request which provokes it:
- # http://www.whatdotheyknow.com/request/reviews_of_unduly_lenient_senten#incoming-4830
+ # Hack round bug in TMail's MIME decoding.
# Report of TMail bug:
# http://rubyforge.org/tracker/index.php?func=detail&aid=21810&group_id=4512&atid=17370
copy_of_raw_data = self.raw_email.data.gsub(/; boundary=\s+"/ims,'; boundary="')
@@ -347,8 +344,7 @@ class IncomingMessage < ActiveRecord::Base
name = Regexp.escape(self.info_request.user_name)
# To end of message sections
- # http://www.whatdotheyknow.com/request/university_investment_in_the_arm
- text.gsub!(/^#{name}[^\n]+\nSent by:[^\n]+\n.*/ims, "\n\n" + replacement)
+ text.gsub!(/^\s?#{name}[^\n]+\n([^\n]+\n)?\s?Sent by:[^\n]+\n.*/ims, "\n\n" + replacement)
# Some other sort of forwarding quoting
# http://www.whatdotheyknow.com/request/224/response/326
@@ -582,7 +578,8 @@ class IncomingMessage < ActiveRecord::Base
# Remove existing quoted sections
folded_quoted_text = self.remove_lotus_quoting(text, 'FOLDED_QUOTED_SECTION')
- folded_quoted_text = IncomingMessage.remove_quoted_sections(text, "FOLDED_QUOTED_SECTION")
+ folded_quoted_text = IncomingMessage.remove_quoted_sections(folded_quoted_text, "FOLDED_QUOTED_SECTION")
+
self.cached_main_body_text_unfolded = text
self.cached_main_body_text_folded = folded_quoted_text
self.save!
@@ -646,6 +643,7 @@ class IncomingMessage < ActiveRecord::Base
# Text looks like unlabelled nonsense,
# strip out anything that isn't UTF-8
begin
+ source_charset = 'utf-8' if source_charset.nil?
text = Iconv.conv('utf-8//IGNORE', source_charset, text) +
_("\n\n[ {{site_name}} note: The above text was badly encoded, and has had strange characters removed. ]",
:site_name => Configuration::site_name)