Skip to content

Commit 93e811c

Browse files
committed
Fix quote_token with frozen AS::Multibyte chars
1 parent 3cdf7f7 commit 93e811c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/mail/utilities.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ def quote_atom( str )
2424
# If the string supplied has PHRASE unsafe characters in it, will return the string quoted
2525
# in double quotes, otherwise returns the string unmodified
2626
def quote_phrase( str )
27-
if RUBY_VERSION >= '1.9'
27+
if str.respond_to?(:force_encoding)
2828
original_encoding = str.encoding
29-
ascii_str = str.dup.force_encoding('ASCII-8BIT')
29+
ascii_str = str.to_s.dup.force_encoding('ASCII-8BIT')
3030
if (PHRASE_UNSAFE === ascii_str)
3131
dquote(ascii_str).force_encoding(original_encoding)
3232
else
@@ -47,7 +47,7 @@ def token_safe?( str )
4747
def quote_token( str )
4848
if str.respond_to?(:force_encoding)
4949
original_encoding = str.encoding
50-
ascii_str = str.dup.force_encoding('ASCII-8BIT')
50+
ascii_str = str.to_s.dup.force_encoding('ASCII-8BIT')
5151
if token_safe?( ascii_str )
5252
str
5353
else

0 commit comments

Comments
 (0)