Mail.read creates an object, but its methods fail with Encoding::UndefinedConversionError #418

Closed
ivanku opened this Issue Jul 12, 2012 · 1 comment

Projects

None yet

2 participants

@ivanku
ivanku commented Jul 12, 2012

Ruby 1.9.3-p125

Email files from SpamAssassin corpus: http://spamassassin.apache.org/publiccorpus/20021010_spam.tar.bz2

0253.f715f442da45114754198a160195b883
0254.02daa37a4255a78f2f224f3cd2f8fa99

> fm = Mail.read("data/bug/0253.f715f442da45114754198a160195b883")
> fm.header
Encoding::UndefinedConversionError: "\xAF" from ASCII-8BIT to UTF-8
    from /home/ivan/.rvm/gems/ruby-1.9.3-p125/gems/mail-2.4.4/lib/mail/fields/unstructured_field.rb:142:in `encode!'
    from /home/ivan/.rvm/gems/ruby-1.9.3-p125/gems/mail-2.4.4/lib/mail/fields/unstructured_field.rb:142:in `fold'
    from /home/ivan/.rvm/gems/ruby-1.9.3-p125/gems/mail-2.4.4/lib/mail/fields/unstructured_field.rb:96:in `wrapped_value'
    from /home/ivan/.rvm/gems/ruby-1.9.3-p125/gems/mail-2.4.4/lib/mail/fields/unstructured_field.rb:60:in `do_encode'
    from /home/ivan/.rvm/gems/ruby-1.9.3-p125/gems/mail-2.4.4/lib/mail/fields/unstructured_field.rb:42:in `encoded'
    from /home/ivan/.rvm/gems/ruby-1.9.3-p125/gems/mail-2.4.4/lib/mail/field.rb:133:in `method_missing'
    from /home/ivan/.rvm/gems/ruby-1.9.3-p125/gems/mail-2.4.4/lib/mail/header.rb:190:in `block in encoded'
    from /home/ivan/.rvm/gems/ruby-1.9.3-p125/gems/mail-2.4.4/lib/mail/header.rb:189:in `each'
    from /home/ivan/.rvm/gems/ruby-1.9.3-p125/gems/mail-2.4.4/lib/mail/header.rb:189:in `encoded'
    from /home/ivan/.rvm/gems/ruby-1.9.3-p125/gems/mail-2.4.4/lib/mail/header.rb:196:in `to_s'
    from /home/ivan/.rvm/rubies/ruby-1.9.3-p125/bin/irb:16:in `<main>'
@jeremy
Collaborator
jeremy commented Jan 27, 2013

This is due to encoding header values with the message's charset (utf-8) when the header is encoded. Raising an exception is appropriate.

@jeremy jeremy closed this Jan 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment