File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -24,9 +24,9 @@ def quote_atom( str )
24
24
# If the string supplied has PHRASE unsafe characters in it, will return the string quoted
25
25
# in double quotes, otherwise returns the string unmodified
26
26
def quote_phrase ( str )
27
- if RUBY_VERSION >= '1.9'
27
+ if str . respond_to? ( :force_encoding )
28
28
original_encoding = str . encoding
29
- ascii_str = str . dup . force_encoding ( 'ASCII-8BIT' )
29
+ ascii_str = str . to_s . dup . force_encoding ( 'ASCII-8BIT' )
30
30
if ( PHRASE_UNSAFE === ascii_str )
31
31
dquote ( ascii_str ) . force_encoding ( original_encoding )
32
32
else
@@ -47,7 +47,7 @@ def token_safe?( str )
47
47
def quote_token ( str )
48
48
if str . respond_to? ( :force_encoding )
49
49
original_encoding = str . encoding
50
- ascii_str = str . dup . force_encoding ( 'ASCII-8BIT' )
50
+ ascii_str = str . to_s . dup . force_encoding ( 'ASCII-8BIT' )
51
51
if token_safe? ( ascii_str )
52
52
str
53
53
else
You can’t perform that action at this time.
0 commit comments