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

cannot correctly decode quoted-printable with CJK UTF-8 string #1402

Closed
tonytonyjan opened this issue Aug 8, 2020 · 3 comments
Closed

cannot correctly decode quoted-printable with CJK UTF-8 string #1402

tonytonyjan opened this issue Aug 8, 2020 · 3 comments

Comments

@tonytonyjan
Copy link

tonytonyjan commented Aug 8, 2020

Environment:

Mail::VERSION::STRING
# => 2.7.1
RUBY_VERSION
# => 2.7.1

Reproduce:

Mail::Encodings.value_decode '=?utf-8?B?MjTmmYLplpPjgIHjg4vjg6Xjg7zjgrnjgajnlarntYTjgpLo?= =?utf-8?B?i7Hoqp7jgafkuJbnlYzjgavnmbrkv6HjgZfjgabjgYTjgb7?='
# => "24時間、ニュースと番組を���語で世界に発信していま"

Base64.decode64('MjTmmYLplpPjgIHjg4vjg6Xjg7zjgrnjgajnlarntYTjgpLoi7Hoqp7jgafkuJbnlYzjgavnmbrkv6HjgZfjgabjgYTjgb7').force_encoding('utf-8')
# => "24時間、ニュースと番組を英語で世界に発信していま"
Mail::Encodings.value_decode '=?utf-8?B?5paw5YyX5biC5pS/5bqc6K2m5a+f5bGALeS6pOmAmumBleim?= =?utf-8?B?j+aqouiIieezu+e1sWUtbWFpbOiqjeitieS/oeS7tg==?='
# => "新北市政府警察局-交通違��檢舉系統e-mail認證信件"

Base64.decode64('5paw5YyX5biC5pS/5bqc6K2m5a+f5bGALeS6pOmAmumBleimj+aqouiIieezu+e1sWUtbWFpbOiqjeitieS/oeS7tg==').force_encoding('utf-8')
# => "新北市政府警察局-交通違規檢舉系統e-mail認證信件"

related source code:

https://github.com/mikel/mail/blob/2.7.1/lib/mail/encodings.rb#L130-L137

@discdisk
Copy link

discdisk commented Aug 13, 2020

I got this problem too
#1397

@tonytonyjan
Copy link
Author

my workaround for b-decoding:

'=?utf-8?B?MjTmmYLplpPjgIHjg4vjg6Xjg7zjgrnjgajnlarntYTjgpLo?= =?utf-8?B?i7Hoqp7jgafkuJbnlYzjgavnmbrkv6HjgZfjgabjgYTjgb7?='
  .split.map{|i| i[10..-3].unpack1('m')}.join.force_encoding('utf-8')
# => "24時間、ニュースと番組を英語で世界に発信していま"

@tonytonyjan
Copy link
Author

moved to #1397

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants