You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2016/09/19 16:41:24 UTC

[whimsy] branch master updated: make liberal email parser an class method

This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git

The following commit(s) were added to refs/heads/master by this push:
       new  5c2edaf   make liberal email parser an class method
5c2edaf is described below

commit 5c2edafa1f040e5b76feeb63fb723ce524be1580
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Mon Sep 19 12:40:53 2016 -0400

    make liberal email parser an class method
---
 www/secmail/models/message.rb | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/www/secmail/models/message.rb b/www/secmail/models/message.rb
index c04f083..5215c37 100644
--- a/www/secmail/models/message.rb
+++ b/www/secmail/models/message.rb
@@ -219,7 +219,7 @@ class Message
     # process 'to' addresses on method call
     if fields[:to]
       Array(fields[:to]).compact.each do |addr|
-        addr = liberal_email_parser(addr) if addr.is_a? String
+        addr = Message.liberal_email_parser(addr) if addr.is_a? String
         next if to.any? {|a| a.address = addr.address}
         to << addr
       end
@@ -245,7 +245,7 @@ class Message
 
     # process 'cc' addresses from original email
     self.cc.each do |addr|
-      addr = liberal_email_parser(addr) if addr.is_a? String
+      addr = Message.liberal_email_parser(addr) if addr.is_a? String
       next if to.any? {|a| a.address == addr.address}
       cc << addr
     end
@@ -253,7 +253,7 @@ class Message
     # process 'cc' addresses on method call
     if fields[:cc]
       Array(fields[:cc]).compact.each do |addr|
-        addr = liberal_email_parser(addr) if addr.is_a? String
+        addr = Message.liberal_email_parser(addr) if addr.is_a? String
         next if to.any? {|a| a.address == addr.address}
         next if cc.any? {|a| a.address == addr.address}
         cc << addr
@@ -263,7 +263,7 @@ class Message
     # process 'bcc' addresses on method call
     if fields[:bcc]
       Array(fields[:bcc]).compact.each do |addr|
-        addr = liberal_email_parser(addr) if addr.is_a? String
+        addr = Message.liberal_email_parser(addr) if addr.is_a? String
         next if to.any? {|a| a.address == addr.address}
         next if cc.any? {|a| a.address == addr.address}
         next if bcc.any? {|a| a.address == addr.address}
@@ -297,7 +297,7 @@ class Message
     begin
       from = liberal_email_parser(mail[:from].value).display_name
     rescue Exception
-      from = mail[:from].value
+      from = mail[:from].value.sub(/\s+<.*?>$/)
     end
 
     # determine who should be copied on any responses
@@ -367,10 +367,8 @@ class Message
     headers
   end
 
-private
-
   # see https://github.com/mikel/mail/issues/39
-  def liberal_email_parser(addr)
+  def self.liberal_email_parser(addr)
     addr = Mail::Address.new(addr)
   rescue Mail::Field::ParseError
     if addr =~ /^"([^"]*)" <(.*)>$/

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].