diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/incoming_message.rb | 24 | ||||
-rw-r--r-- | app/models/request_mailer.rb | 6 |
2 files changed, 26 insertions, 4 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 7071970dc..c354a8554 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.140 2008-08-31 12:46:15 francis Exp $ +# $Id: incoming_message.rb,v 1.141 2008-09-01 16:09:18 francis Exp $ # TODO # Move some of the (e.g. quoting) functions here into rblib, as they feel @@ -54,6 +54,28 @@ module TMail return nil end end + + end + + class Address + # Monkeypatch! + def Address.encode_quoted_string(text) + if text.match(/[^A-Za-z0-9!#\$%&'*+\-\/=?^_`{|}~]/) + # Contains characters which aren't valid in atoms, so make a + # quoted-pair instead. + text.gsub!(/(["\\])/, "\\\\\\1") + text = '"' + text + '"' + end + return text + end + + def quoted_full + if self.name + Address.encode_quoted_string(self.name) + " <" + self.spec + ">" + else + self.spec + end + end end end diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb index 3d30e8418..1ffdd1e4c 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.50 2008-09-01 15:10:17 francis Exp $ +# $Id: request_mailer.rb,v 1.51 2008-09-01 16:09:18 francis Exp $ class RequestMailer < ApplicationMailer @@ -31,7 +31,7 @@ class RequestMailer < ApplicationMailer if incoming_message_followup.nil? return info_request.recipient_name_and_email else - return incoming_message_followup.mail.from_addrs.to_s + return incoming_message_followup.mail.from_addrs[0].quoted_full end end # Used in the preview of followup @@ -46,7 +46,7 @@ class RequestMailer < ApplicationMailer # Incoming message arrived for a request, but new responses have been stopped. def stopped_responses(info_request, email) @from = contact_from_name_and_email - @recipients = email.from_addrs.to_s + @recipients = email.from_addrs[0].quoted_full @subject = "Your response to an FOI request was not delivered" email.setup_forward(self) @body = { |