Skip to content

Commit

Permalink
Fix quote_token with frozen AS::Multibyte chars
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy committed Feb 28, 2018
1 parent 3cdf7f7 commit 93e811c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/mail/utilities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 93e811c

Please sign in to comment.