From 79a1cce8d1ffca97fa0e4a639134aae6e55c76df Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Mon, 28 Mar 2011 12:01:17 +0100 Subject: [PATCH] Reduce scope of special case for matching '@' in display name - was matching in case of multiple addresses with unquoted display names. --- lib/tmail/parser.rb | 2 +- test/test_header.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/tmail/parser.rb b/lib/tmail/parser.rb index 1d4dcc2..76aa20a 100644 --- a/lib/tmail/parser.rb +++ b/lib/tmail/parser.rb @@ -56,7 +56,7 @@ def self.special_quote_address(str) #:nodoc: # around the display name when the display name contains a '@' # like 'mikel@me.com ' # Just quotes it to: '"mikel@me.com" ' - when str =~ /\A([^"].+@.+[^"])\s(<.*?>)\Z/ + when str =~ /\A([^"][^<]+@[^>]+[^"])\s(<.*?>)\Z/ return "\"#{$1}\" #{$2}" # This handles cases where 'Mikel A. ' which is a trailing # full stop before the address section. Just quotes it to diff --git a/test/test_header.rb b/test/test_header.rb index 78b7418..d393bc9 100644 --- a/test/test_header.rb +++ b/test/test_header.rb @@ -154,6 +154,17 @@ def test_ATTRS :routes => [], :spec => 'hoge@example.jp'}] } + + validate_case 'Mikel , another Mikel ', + false, + 'Mikel , another Mikel ', + [], + [{ :phrase => 'Mikel', + :routes => [], + :spec => 'mikel@me.org' }, + { :phrase => 'another Mikel', + :routes => [], + :spec => 'mikel@you.org' }] end end