Open
Description
Headers in email are defined to be ASCII only (or UTF-8 if you're experimenting with RFC 5335). They should not be any other character encoding.
At the moment the mail gem decodes headers that appear after the Content-Type header with the same charset as specified there. This is wrong, and causes strange errors with some character encodings:
pry> Mail.new("Content-Type: text/plain; charset=iso-2022-jp\r\nSubject: Test\r\n\r\nTest\r\n").encoded
Encoding::CompatibilityError: incompatible encoding regexp match (US-ASCII regexp with ISO-2022-JP string)
from /home/conrad/.rvm/gems/ruby-1.9.3-p194@foo/bundler/gems/mail-de4eec71b0b2/lib/mail/fields/unstructured_field.rb:179:in `gsub!'