Skip to content

Address list with comment before address parses incorrectly if no space after comma #1578

Open
@HermanHiddema

Description

@HermanHiddema

Given the following five examples:

Mail::AddressList.new("[email protected],[email protected]")
Mail::AddressList.new("(comment) [email protected],[email protected]")
Mail::AddressList.new("[email protected],(comment) [email protected]")
Mail::AddressList.new("[email protected], (comment) [email protected]")
Mail::AddressList.new("[email protected],(comment) [email protected],[email protected]")

If I run these, I get weird results on case 3 and case 5:

[1] pry(main)> require 'mail';
[2] pry(main)> Mail::AddressList.new("[email protected],[email protected]")
=> #<Mail::AddressList:0x000055ca6eb5a638
 @addresses=
  [#<Mail::Address:940 Address: |[email protected]| >,
   #<Mail::Address:960 Address: |[email protected]| >],
 @group_names=[]>
[3] pry(main)> Mail::AddressList.new("(comment) [email protected],[email protected]")
=> #<Mail::AddressList:0x000055ca6ea2e6d8
 @addresses=
  [#<Mail::Address:980 Address: |"(comment)" <[email protected]> (comment)| >,
   #<Mail::Address:1000 Address: |[email protected]| >],
 @group_names=[]>
[4] pry(main)> Mail::AddressList.new("[email protected],(comment) [email protected]")
=> #<Mail::AddressList:0x000055ca6e976970
 @addresses=[#<Mail::Address:1020 Address: |[email protected]| >],
 @group_names=[]>
[5] pry(main)> Mail::AddressList.new("[email protected], (comment) [email protected]")
=> #<Mail::AddressList:0x000055ca6e86dd08
 @addresses=
  [#<Mail::Address:1040 Address: |[email protected]| >,
   #<Mail::Address:1060 Address: |"(comment)" <[email protected]> (comment)| >],
 @group_names=[]>
[6] pry(main)> Mail::AddressList.new("[email protected],(comment) [email protected],[email protected]")
=> #<Mail::AddressList:0x000055ca6e799ee0
 @addresses=
  [#<Mail::Address:1080 Address: |[email protected]| >,
   #<Mail::Address:1100 Address: |"(comment)" <[email protected]> (comment)| >],
 @group_names=[]>

Cases 2 and 3 are identical, except that the addresses have been swapped, so I'd expect it to work.

The fact that case 4 is correct, means that the parser is sensitive to the white space behind the comma after the first address.

Case 5 really shows that the parser gets confused, it adds the comment from the second address to the third one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions