From cf4604e639b252da634834c8d577341a3fa4ec43 Mon Sep 17 00:00:00 2001 From: mikel Date: Mon, 17 Nov 2008 14:32:16 +0000 Subject: [PATCH] Removing . and @ hack for Alexey to look at --- lib/tmail/address.rb | 4 ++-- test/fixtures/raw_email_double_at_in_header | 14 ++++++++++++++ test/fixtures/raw_email_trailing_dot | 21 +++++++++++++++++++++ test/test_address.rb | 7 +++++++ 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 test/fixtures/raw_email_double_at_in_header create mode 100644 test/fixtures/raw_email_trailing_dot diff --git a/lib/tmail/address.rb b/lib/tmail/address.rb index 2e2992c..47d3ebc 100644 --- a/lib/tmail/address.rb +++ b/lib/tmail/address.rb @@ -81,7 +81,7 @@ class Address # # Raises a TMail::SyntaxError on invalid email format def Address.parse( str ) - Parser.parse :ADDRESS, special_quote_address(str) + Parser.parse :ADDRESS, (str) end def Address.special_quote_address(str) #:nodoc: @@ -110,7 +110,7 @@ def Address.special_quote_address(str) #:nodoc: return "\"#{$1}\" #{$2}" # This handles cases where 'Mikel A. ' which is a trailing # full stop before the address section. Just quotes it to - # '"Mikel A. " + # '"Mikel A." ' when str =~ /\A(.*?\.)\s(<.*?>)\Z/ return "\"#{$1}\" #{$2}" else diff --git a/test/fixtures/raw_email_double_at_in_header b/test/fixtures/raw_email_double_at_in_header new file mode 100644 index 0000000..277e862 --- /dev/null +++ b/test/fixtures/raw_email_double_at_in_header @@ -0,0 +1,14 @@ +From jamis_buck@byu.edu Mon May 2 16:07:05 2005 +Mime-Version: 1.0 (Apple Message framework v622) +Content-Transfer-Encoding: base64 +Message-Id: +Content-Type: text/plain; + charset=EUC-KR; + format=flowed +To: willard15georgina@jamis.backpackit.com +From: Jamis Buck +Subject: =?EUC-KR?Q?NOTE:_=C7=D1=B1=B9=B8=BB=B7=CE_=C7=CF=B4=C2_=B0=CD?= +Date: Mon, 2 May 2005 16:07:05 -0600 + +tOu6zrrQwMcguLbC+bChwfa3ziwgv+y4rrTCIMfPs6q01MC7ILnPvcC0z7TZLg0KDQrBpiDAzLin +wLogSmFtaXPA1LTPtNku diff --git a/test/fixtures/raw_email_trailing_dot b/test/fixtures/raw_email_trailing_dot new file mode 100644 index 0000000..137bcbf --- /dev/null +++ b/test/fixtures/raw_email_trailing_dot @@ -0,0 +1,21 @@ +Delivered-To: xxx@xxx.com +Received: by 10.67.31.8 with SMTP id i8cs1195ugj; + Mon, 22 Sep 2008 13:45:18 -0700 (PDT) +Received: by 10.100.207.5 with SMTP id e5mr3483815ang.104.1222110393505; + Mon, 22 Sep 2008 12:06:33 -0700 (PDT) +Return-Path: +Received: from rubyforge.org (rubyforge.org [205.234.109.19]) + by mx.google.com with ESMTP id c2si899474ana.10.2008.09.22.12.06.28; + Mon, 22 Sep 2008 12:06:33 -0700 (PDT) +Received-SPF: pass (google.com: best guess record for domain of noreply@rubyforge.org designates 205.234.109.19 as permitted sender) client-ip=205.234.109.19; +Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of noreply@rubyforge.org designates 205.234.109.19 as permitted sender) smtp.mail=noreply@rubyforge.org +Received: by rubyforge.org (Postfix, from userid 502) + id 8FB1518581AC; Mon, 22 Sep 2008 15:06:28 -0400 (EDT) +To: noreply@rubyforge.org +From: Sandy M. +Subject: [skynet-help][60666] How are intermediate files handled in SkyNet? +Content-type: text/plain; charset=UTF-8 +Message-Id: <20080922190628.8FB1518581AC@rubyforge.org> +Date: Mon, 22 Sep 2008 15:06:28 -0400 (EDT) + +Testing, testing, 123. \ No newline at end of file diff --git a/test/test_address.rb b/test/test_address.rb index f654eb5..e1fbe6c 100644 --- a/test/test_address.rb +++ b/test/test_address.rb @@ -1204,4 +1204,11 @@ def test_at_char_in_address() :format => %Q(mikel ) end + def test_trailing_dot_in_name + fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email_trailing_dot") + str = 'Sandy M. ' + mail = TMail::Mail.parse(fixture) + assert_equal str, mail.from + end + end