Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
HermanHiddema opened this issue May 9, 2023 · 0 comments

Comments

@HermanHiddema
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant