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

failing spec for non-ascii local address #1087

Closed
wants to merge 3 commits into from

Conversation

@estraph
Copy link

commented Apr 13, 2017

the AddressListsParser can't seem to handle non-ASCII characters. I wrote a failing spec to demonstrate. I don't know Ragel at all, so having a hard time to pinpoint where this could be fixed (or if it's even a bug at all). Issue: #1088 Issue: #39

Failures:

  1) AddressListsParser email with non-ascii characters
     Failure/Error: raise Mail::Field::ParseError.new(Mail::AddressList, data, "Only able to parse up to #{data[0..p]}")
     Mail::Field::ParseError:
       Mail::AddressList can not parse |Dude <düde@somewhere.com>|
       Reason was: Only able to parse up to Dude <# ./lib/mail/parsers/address_lists_parser.rb:15336:in `parse'
     # ./spec/mail/parsers/address_lists_parser_spec.rb:9:in `block (3 levels) in <top (required)>'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/memoized_helpers.rb:295:in `block (2 levels) in let'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/memoized_helpers.rb:157:in `block (3 levels) in fetch_or_store'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/memoized_helpers.rb:157:in `fetch'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/memoized_helpers.rb:157:in `block (2 levels) in fetch_or_store'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-support-3.5.0/lib/rspec/support/reentrant_mutex.rb:23:in `synchronize'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/memoized_helpers.rb:156:in `block in fetch_or_store'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/memoized_helpers.rb:155:in `fetch'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/memoized_helpers.rb:155:in `fetch_or_store'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/memoized_helpers.rb:295:in `block in let'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/memoized_helpers.rb:119:in `is_expected'
     # ./spec/mail/parsers/address_lists_parser_spec.rb:11:in `block (3 levels) in <top (required)>'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:254:in `instance_exec'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:254:in `block in run'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:496:in `block in with_around_and_singleton_context_hooks'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:453:in `block in with_around_example_hooks'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:464:in `block in run'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:602:in `run_around_example_hooks_for'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/hooks.rb:464:in `run'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:453:in `with_around_example_hooks'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:496:in `with_around_and_singleton_context_hooks'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/example.rb:251:in `run'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:627:in `block in run_examples'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:623:in `map'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:623:in `run_examples'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:589:in `run'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:590:in `block in run'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:590:in `map'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:590:in `run'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:113:in `block (3 levels) in run_specs'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:113:in `map'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:113:in `block (2 levels) in run_specs'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1835:in `with_suite_hooks'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:112:in `block in run_specs'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/reporter.rb:77:in `report'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:111:in `run_specs'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:87:in `run'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:71:in `run'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:45:in `invoke'
     # /usr/local/lib/ruby/gems/2.4.0/gems/rspec-core-3.5.4/exe/rspec:4:in `<main>'

Finished in 3.45 seconds (files took 0.69263 seconds to load)
1618 examples, 1 failure, 8 pending

Failed examples:

rspec ./spec/mail/parsers/address_lists_parser_spec.rb:11 # AddressListsParser email with non-ascii characters
@vgoodman

This comment has been minimized.

Copy link

commented Apr 21, 2017

I ran into the same issue today. It seems like the last comment in this PR(#685) might be helpful if you'd like to avoid Ragal :)

Call encoded = Mail::Encodings.address_encode(addr) before calling Mail::AddressList.new(encoded)

@jeremy

This comment has been minimized.

Copy link
Collaborator

commented May 14, 2017

With #1103:

>> Mail::Address.new('Dude <düde@somewhere.com>').address
=> "düde@somewhere.com"

😊

@jeremy jeremy closed this May 14, 2017

@pratik60

This comment has been minimized.

Copy link

commented May 14, 2017

Thanks so much for fixing this... We can't wait to test it out in production here pending 2.7.0 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.