File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change 1313module Spring
1414 module JSON
1515 def self . load ( string )
16+ string = string . dup . force_encoding ( "utf-8" ) unless string . encoding == Encoding ::UTF_8
1617 OkJson . decode ( string )
1718 end
1819
Original file line number Diff line number Diff line change @@ -6,7 +6,12 @@ class JsonTest < ActiveSupport::TestCase
66 assert_equal ( { "unicode_example" => "©" } , Spring ::JSON . load ( '{"unicode_example": "\u00A9"}' ) )
77 end
88
9+ test 'can decode binary strings with valid UTF8 characters' do
10+ string = "{\" PS1\" :\" \xEF \x90 \x98 main \xEE \x9E \x91 v3.4.2\" }" . b
11+ assert_equal ( { "PS1" => " main v3.4.2" } , Spring ::JSON . load ( string ) )
12+ end
13+
914 test 'can encode' do
1015 assert_equal ( '{}' , Spring ::JSON . dump ( { } ) )
11- end
16+ end
1217end
You can’t perform that action at this time.
0 commit comments