diff options
Diffstat (limited to 'app/models/incoming_message.rb')
-rw-r--r-- | app/models/incoming_message.rb | 24 |
1 files changed, 23 insertions, 1 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 |