aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/incoming_message.rb10
-rw-r--r--app/models/request_mailer.rb8
-rw-r--r--lib/tmail_extensions.rb7
3 files changed, 16 insertions, 9 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index d531f4eb7..99f270049 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.204 2009-05-19 01:13:48 francis Exp $
+# $Id: incoming_message.rb,v 1.205 2009-05-21 01:18:45 francis Exp $
# TODO
# Move some of the (e.g. quoting) functions here into rblib, as they feel
@@ -1054,10 +1054,12 @@ class IncomingMessage < ActiveRecord::Base
# Returns the name of the person the incoming message is from, or nil if
# there isn't one or if there is only an email address. XXX can probably
- # remove this and from_name_if_present (which is a monkey patch) by just
- # calling .from_addrs[0].name instead? (as RequestMailer.name_for_followup etc. do)
+ # remove from_name_if_present (which is a monkey patch) by just calling
+ # .from_addrs[0].name here instead?
def safe_mail_from
- self.mail.from_name_if_present
+ name = self.mail.from_name_if_present
+ name = self.info_request.apply_censor_rules_to_text(name)
+ return name
end
def mail_from_domain
diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb
index c7804d435..16bdba911 100644
--- a/app/models/request_mailer.rb
+++ b/app/models/request_mailer.rb
@@ -4,7 +4,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: request_mailer.rb,v 1.74 2009-04-14 11:16:41 louise Exp $
+# $Id: request_mailer.rb,v 1.75 2009-05-21 01:18:45 francis Exp $
class RequestMailer < ApplicationMailer
@@ -37,7 +37,8 @@ class RequestMailer < ApplicationMailer
if incoming_message_followup.nil? || !incoming_message_followup.valid_to_reply_to?
return info_request.recipient_name_and_email
else
- return incoming_message_followup.mail.from_addrs[0].to_s
+ # calling safe_mail_from from so censor rules are run
+ return TMail::Address.address_from_name_and_email(incoming_message_followup.safe_mail_from, incoming_message_followup.mail.from_addrs[0].spec).to_s
end
end
# Used in the preview of followup
@@ -45,7 +46,8 @@ class RequestMailer < ApplicationMailer
if incoming_message_followup.nil? || !incoming_message_followup.valid_to_reply_to?
return info_request.public_body.name
else
- return incoming_message_followup.mail.from_addrs[0].name || info_request.public_body.name
+ # calling safe_mail_from from so censor rules are run
+ return incoming_message_followup.safe_mail_from || info_request.public_body.name
end
end
# Used when making list of followup places to remove duplicates
diff --git a/lib/tmail_extensions.rb b/lib/tmail_extensions.rb
index 711463050..66bf8bab1 100644
--- a/lib/tmail_extensions.rb
+++ b/lib/tmail_extensions.rb
@@ -4,7 +4,7 @@
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: tmail_extensions.rb,v 1.3 2009-04-08 07:31:08 francis Exp $
+# $Id: tmail_extensions.rb,v 1.4 2009-05-21 01:18:45 francis Exp $
# Monkeypatch!
@@ -35,9 +35,12 @@ module TMail
# Monkeypatch! Constructor which makes a TMail::Address given
# a name and an email
def Address.address_from_name_and_email(name, email)
+ if name.nil?
+ return TMail::Address.parse(email)
+ end
# Botch an always quoted RFC address, then parse it
name = name.gsub(/(["\\])/, "\\\\\\1")
- TMail::Address.parse('"' + name + '" <' + email + '>')
+ return TMail::Address.parse('"' + name + '" <' + email + '>')
end
end