-
Notifications
You must be signed in to change notification settings - Fork 931
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
Mail.new fails to parse UTF-8 characters in to: field #685
Comments
Mail::Address.new("Jure Žove <jure.pase.kure@gmail.com>")
Mail::Field::ParseError: Mail::AddressListsParser can not parse |Jure Žove <jure.pase.kure@gmail.com>| Mail::Address.new("=?UTF-8?B?SnVyZSDFvW92ZQ==?= <jure.pase.kure@gmail.com>")
=> #<Mail::Address:70093092354000 Address: |"Jure Žove" <jure.pase.kure@gmail.com>| > Maybe this is expected, since the display name must be encoded. |
Thanks, can you please provide a way how I could encode it and still preserve the character? |
$ > addr = Mail::Address.new('jure.pase.kure@gmail.com')
=> #<Mail::Address:70197914477980 Address: |jure.pase.kure@gmail.com| >
$ > addr.display_name = 'Jure Žove'
=> "Jure Žove"
$ > addr.encoded()
=> "=?UTF-8?B?SnVyZSDFvW92ZQ==?= <jure.pase.kure@gmail.com>"
$ > addr.decoded()
=> "\"Jure Žove\" <jure.pase.kure@gmail.com>" |
What about if I already receive a mail want get the display name of the to or from fields? I would probably need to encode the string ("Jure Žove email@email.com") before I try to parse it? |
Look at the original unmodified email, the UTF-8 characters should be encoded. Like I received an email notification from GitHub and it had this |
The thing is I'm getting this through a JSON request from Mailgun which is already in UTF-8 (not encoded). |
Ultimately, the decoded address would have to be parsed. The |
Okay, thanks! Will look into that. |
Related to #39 |
Why was this issue closed? I'm also having troubles parsing these malformed headers. One of the offending headers I'm getting is: Note that Gmail is able to correctly parse this header, and that it is not encoded. |
@sk- If you are trying to use |
These are fixed by #1103: >> Mail.new(to: "Jure Žove <jure.pase.kure@gmail.com>").to
=> ["jure.pase.kure@gmail.com"]
>> Mail.new("From: ÁREA DE DEPORTES Y RECREACIÓN<foo@foo.com>").from
=> ["foo@foo.com"] |
The text was updated successfully, but these errors were encountered: