lib/mail_address/address.rb in mail_address-1.2.15 vs lib/mail_address/address.rb in mail_address-1.2.16

- old
+ new

@@ -17,30 +17,30 @@ # invalid address @phrase = original if @address.nil? end - ATEXT = '[\-\w !#$%&\'*+/=?^`{|}~]' + ATEXT = '[\-\w\s!#$%&\'*+/=?^`{|}~]' def format(enquote = false) addr = [] return @original.gsub(/[;,]/, '') if @address.nil? email_address = enquote ? quoted_address : @address - if !@phrase.nil? && @phrase.length > 0 then + if !@phrase.nil? && @phrase.length > 0 # if @phrase.match(/\A\(/) && @phrase.match(/\)\z/) # addr.push(email_address) if !@address.nil? && @address.length > 0 # addr.push(@phrase) # else addr.push( - @phrase.match(/^(?:\s*#{ATEXT}\s*)+$/) ? @phrase - : @phrase.match(/(?<!\\)"/) ? @phrase + @phrase.match(/^(?:#{ATEXT})+$/) ? @phrase + : @phrase.match(/(?<!\\)"/) ? @phrase : %Q("#{@phrase}") ) addr.push "<#{email_address}>" if !@address.nil? && @address.length > 0 # end - elsif !@address.nil? && @address.length > 0 then + elsif !@address.nil? && @address.length > 0 addr.push(email_address) end addr.join(' ') end