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