diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/incoming_message.rb | 5 | ||||
-rw-r--r-- | app/models/outgoing_message.rb | 10 |
2 files changed, 11 insertions, 4 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 3ea42179d..2f1184687 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.104 2008-05-22 11:23:14 francis Exp $ +# $Id: incoming_message.rb,v 1.105 2008-05-27 08:56:27 francis Exp $ # TODO # Move some of the (e.g. quoting) functions here into rblib, as they feel @@ -215,8 +215,7 @@ text = IncomingMessage.mask_string_multicharset(text, 'request-144-a724c835@what # Remove any email addresses - we don't want bounce messages to leak out # either the requestor's email address or the request's response email # address out onto the internet - rx = Regexp.new("(\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}\\b)") - text.gsub!(rx, "[email address]") + text.gsub!(MySociety::Validate.email_find_regexp, "[email address]") return text end diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index 75477706e..c975e50ec 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -21,7 +21,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: outgoing_message.rb,v 1.50 2008-05-21 10:51:24 francis Exp $ +# $Id: outgoing_message.rb,v 1.51 2008-05-27 08:56:27 francis Exp $ class OutgoingMessage < ActiveRecord::Base belongs_to :info_request @@ -65,6 +65,14 @@ class OutgoingMessage < ActiveRecord::Base ret.sub!(/Dear .+,/, "") return ret end + + # Used to give warnings when writing new messages + def contains_email? + MySociety::Validate.email_find_regexp.match(self.body) + end + def contains_postcode? + MySociety::Validate.contains_postcode?(self.body) + end # Set default letter def after_initialize |