From 93e811c791ef92cbfdceb1e11970d02530f6b8cd Mon Sep 17 00:00:00 2001 From: Jeremy Daer Date: Wed, 28 Feb 2018 10:11:27 -0800 Subject: [PATCH] Fix quote_token with frozen AS::Multibyte chars --- lib/mail/utilities.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/mail/utilities.rb b/lib/mail/utilities.rb index e07d3526a..a2359558a 100644 --- a/lib/mail/utilities.rb +++ b/lib/mail/utilities.rb @@ -24,9 +24,9 @@ def quote_atom( str ) # If the string supplied has PHRASE unsafe characters in it, will return the string quoted # in double quotes, otherwise returns the string unmodified def quote_phrase( str ) - if RUBY_VERSION >= '1.9' + if str.respond_to?(:force_encoding) original_encoding = str.encoding - ascii_str = str.dup.force_encoding('ASCII-8BIT') + ascii_str = str.to_s.dup.force_encoding('ASCII-8BIT') if (PHRASE_UNSAFE === ascii_str) dquote(ascii_str).force_encoding(original_encoding) else @@ -47,7 +47,7 @@ def token_safe?( str ) def quote_token( str ) if str.respond_to?(:force_encoding) original_encoding = str.encoding - ascii_str = str.dup.force_encoding('ASCII-8BIT') + ascii_str = str.to_s.dup.force_encoding('ASCII-8BIT') if token_safe?( ascii_str ) str else