Giter Site home page Giter Site logo

Comments (36)

nburwell avatar nburwell commented on June 3, 2024 1

Since we are still on Ruby 1.8.7 and could not use the proposed patch to the treetop grammar by @tessi, as a workaround, we used the stringex gem, which adds a to_ascii method to String.

> m = Mail::Address.new('"Stéphane Guillou" <[email protected]>'.to_ascii)
=> ...
> m.name
=> "Stephane Guillou"
> m.address
=> "[email protected]"

That at least gets around the parse error and will convert special characters to their closest ascii equivalent.

from mail.

beders avatar beders commented on June 3, 2024 1

Thanks for working on this. It is greatly appreciated.
I tested with 2.7.0.rc1 but it doesn't seem to be happy with umlauts:
Here's an example:

>> puts Gem.loaded_specs["mail"].version
2.7.0.rc1
nil
>> Mail::Address.new('über <[email protected]>')
Mail::Field::ParseError: Mail::AddressList can not parse |über <[email protected]>|
Reason was: Only able to parse up to ü
	from /Users/beders/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/mail-2.7.0.rc1/lib/mail/parsers/address_lists_parser.rb:15336:in `parse'
	from /Users/beders/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/mail-2.7.0.rc1/lib/mail/elements/address.rb:191:in `parse'
	from /Users/beders/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/mail-2.7.0.rc1/lib/mail/elements/address.rb:31:in `initialize'
	from (irb):9:in `new'
	from (irb):9

from mail.

kevn avatar kevn commented on June 3, 2024

This is RFC 5335: http://tools.ietf.org/html/rfc5335 Not sure how many MTAs support it, but we do have them in our system.

from mail.

mikel avatar mikel commented on June 3, 2024

Yeah, I think the questions is, do I just pass on the non us-ascii chars or do I have Mail try to encode the incoming text stream by guessing?

Auto encode is not trivial but I think it is the way to go.

Mikel

from mail.

mikel avatar mikel commented on June 3, 2024

OK, so I have now released Mail 2.2.0. Can you try again and let me know? It should be fixed.

from mail.

blackwinter avatar blackwinter commented on June 3, 2024

Same problem here. Not fixed by 2.2.0:

Mail::Address.new("josé[email protected]")
Mail::Field::ParseError: AddressListsParser can not parse |josé[email protected]|
Reason was: Expected one of !, #, $, %, &, ', *, +, -, /, =, ?, ^, _, `, {, |, }, ~,
, (, ", ., :, <, @, , at line 1, column 4 (byte 4) after

    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.0/lib/mail/elements/address_list.rb:29:in `initialize'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.0/lib/mail/elements/address.rb:179:in `new'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.0/lib/mail/elements/address.rb:179:in `parse'
    from /usr/lib/ruby/gems/1.8/gems/mail-2.2.0/lib/mail/elements/address.rb:32:in `initialize'
    from (irb):3:in `new'
    from (irb):3

Mail::VERSION::STRING
=> "2.2.0"

It used to work with TMail, though:

TMail::Address.parse("josé[email protected]").address
=> ""josé"[email protected]"

Unfortunately, we can't switch to Mail until non-ASCII addresses are accepted.

cheers
jens

from mail.

mikel avatar mikel commented on June 3, 2024

This should work now. Could you please check against the latest mail gem?

from mail.

kevn avatar kevn commented on June 3, 2024

mikel - it seems to not yet work (v2.2.4), is that the version you're referring to? Here's a gist that I used to test: http://gist.github.com/440075

I tried with ruby 1.8.7 and 1.9.2 with source encoding to see if that had anything to do with it, but I still get the same errors:


Ruby version: 1.9.2
Mail gem version: 2.2.4
Source encoding: ASCII-8BIT
String encoding: ASCII-8BIT
/Users/kevin/.rvm/gems/ruby-1.9.2-head/gems/mail-2.2.4/lib/mail/elements/address_list.rb:29:in `initialize': AddressListsParser can not parse |josé[email protected]| (Mail::Field::ParseError)
Reason was: Expected one of !, #, $, %, &, ', *, +, -, /, =, ?, ^, _, `, {, |, }, ~, 
, (, ", ., :, <, @, , at line 1, column 4 (byte 4) after 
    from /Users/kevin/.rvm/gems/ruby-1.9.2-head/gems/mail-2.2.4/lib/mail/elements/address.rb:179:in `new'
    from /Users/kevin/.rvm/gems/ruby-1.9.2-head/gems/mail-2.2.4/lib/mail/elements/address.rb:179:in `parse'
    from /Users/kevin/.rvm/gems/ruby-1.9.2-head/gems/mail-2.2.4/lib/mail/elements/address.rb:32:in `initialize'
    from mail_i18n_address.rb:18:in `new'
    from mail_i18n_address.rb:18:in `'

FWIW, gmail doesn't support these addresses, so I have no idea how anyone uses addresses like these in the wild.

from mail.

mikel avatar mikel commented on June 3, 2024

OK, we just released mail-2.2.5, please check again?

Mikel

from mail.

jjulian avatar jjulian commented on June 3, 2024

This is still an outstanding issue with mail-2.2.14

Mail::Address.new("josé[email protected]")
AddressListsParser can not parse |josé[email protected]| (Mail::Field::ParseError)
Reason was: Expected one of !, #, $, %, &, ', *, +, -, /, =, ?, ^, _, `, {, |, }, ~, , (, ", ., :, <, @, , at line 1, column 4 (byte 4) after 
from /gems/mail-2.2.14/lib/mail/elements/address.rb:179:in `new'
from /gems/mail-2.2.14/lib/mail/elements/address.rb:179:in `parse'
from /gems/mail-2.2.14/lib/mail/elements/address.rb:32:in `initialize'

from mail.

jjulian avatar jjulian commented on June 3, 2024

An update - this still an issue with mail-2.3.0 on ree-1.8.7-2011.02

from mail.

kewinwang avatar kewinwang commented on June 3, 2024

if my mail from with
from "tuanpin Support---团拼网[email protected]"
Mail::Message#deliver! failed with Mail::Field::ParseError: AddressListsParser can not parse |Tuanpin Support---团拼网[email protected]|
how to fix it ?

from mail.

antekpiechnik avatar antekpiechnik commented on June 3, 2024

Hey, did anyone come up with a workaround for this issue ?

from mail.

alvarezm50 avatar alvarezm50 commented on June 3, 2024

Is this fixed?

from mail.

maccman avatar maccman commented on June 3, 2024

Just came across this issue - any updates?

from mail.

abhishiv avatar abhishiv commented on June 3, 2024

Just FYI

Even addresses like this fail

"Stéphane Guillou" <[email protected]>

This is RFC complaint I guess, but still fails.

from mail.

lunaru avatar lunaru commented on June 3, 2024

Any word on this? With TMail out of the Ruby ecosystem, Mail is the only viable email gem out there and this fails:

Mail::Address.new '"你好" <[email protected]>'

If this isn't something that Mail should be handling, is there a better way in Ruby to parse names and emails from the example email format?

from mail.

esdu avatar esdu commented on June 3, 2024

Any update on this?

from mail.

tessi avatar tessi commented on June 3, 2024

I'm stuck at the same error with Mail::Address.new ""Ää Öö" [email protected]" (german umlauts in the display name).

Is there any progress with this issue?

from mail.

tessi avatar tessi commented on June 3, 2024

FYI: do not take the commits above too serious. It fixes the failure I observed in ruby 1.9.x, but I don't see a way to make it work in 1.8.7. I'm still trying to find a way around that.

I'm not sure if UTF-8 characters in the display_name are RFC complaint. Section 2.2 of RFC 2822 says that any header field (including the from header) "MUST be composed of printable US-ASCII characters". Anyways, there are UTF-8 characters in the field, so I think we should be able to parse them.

from mail.

jeremy avatar jeremy commented on June 3, 2024

Note that you should only be receiving emails with unencoded utf-8 in the headers if your SMTP server supports the SMTPUTF8 extension. If you disable that, the sender should pass along normal ASCII messages.

We'll definitely want to support email internationalization efforts, but that's a giant, separate effort. The standards have been in the works for years now. Check out RFC 6532: http://datatracker.ietf.org/doc/rfc6532/

from mail.

edisgreat avatar edisgreat commented on June 3, 2024

This seems to be a problem with Rails 4, Ruby version 2.1.0:

> Mail::Address.new "\"Ää Öö\" [email protected]"
=> Mail::Field::ParseError: Mail::AddressListsParser can not parse |"Ää Öö" [email protected]|
Reason was: Expected one of 
, \, " at line 1, column 2 (byte 2) after "

from mail.

wmorgan avatar wmorgan commented on June 3, 2024

If you're interested in a workaround, here's a mess of regexes that parses addresslists:

https://gist.github.com/wmorgan/cd5a17616a864fed6108

It ain't pretty (then again, neither is ragel generated code), but it handles utf-8 strings just fine.

from mail.

ckarbass avatar ckarbass commented on June 3, 2024

I'm seeing this as well with Rails 4 Ruby 2.0.0, has this been reopened?

from mail.

rcaught avatar rcaught commented on June 3, 2024

Seeing this with Rails 4.1.4, Ruby 2.1.2p95 and mail (2.5.4)

from mail.

matisojka avatar matisojka commented on June 3, 2024

Seeing this as well, with Rails 3.2.19, Ruby 2.1.1 and mail 2.5.4

from mail.

gr8bit avatar gr8bit commented on June 3, 2024
Mail::Field::ParseError: Mail::AddressList can not parse |test@jobblödel.de| Reason was: Only able to parse up to test@jobblö

Still persists with mail 2.6.1 and Rails 4.1.6/Ruby 2.0.0p481 it seems :/

from mail.

bf4 avatar bf4 commented on June 3, 2024

@jeremy should we re-open this issue or lock the comments?

from mail.

gr8bit avatar gr8bit commented on June 3, 2024

First of all, thanks for this gem (in both meanings)! If you close this issue, please link to a fix/workaround. Google actually ranks this issue very high in search results for this bug.

Cheers

from mail.

jeremy avatar jeremy commented on June 3, 2024

To address this, we'll need to implement RFC 6532 support: #39 (comment)

Please do investigate! Your implementation and pull requests are welcome ❤️

from mail.

jeremy avatar jeremy commented on June 3, 2024

Unlocked so this original issue can remain a magnet for questions, discussion, and yes, the inevitable +1s 😗

from mail.

lunaru avatar lunaru commented on June 3, 2024

Which version of mail will include this fix? I see that it's not in the latest 2.6 release yet. Is this something slated for 2.7.x?

from mail.

jeremy avatar jeremy commented on June 3, 2024

@lunaru 2.7.0! You can try with 2.7.0.rc1 or bundle against the master branch.

from mail.

lunaru avatar lunaru commented on June 3, 2024

@beders I had the same problem. It looks like it's not in the 2.7.0.rc1 branch, but rather only on master still

from mail.

beders avatar beders commented on June 3, 2024

@lunaru Thank you! That indeed works!

from mail.

thromera avatar thromera commented on June 3, 2024

Bump, any fixes scheduled to head on the master branch? Thanks.

from mail.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.