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 13
13
module Spring
14
14
module JSON
15
15
def self . load ( string )
16
+ string = string . dup . force_encoding ( "utf-8" ) unless string . encoding == Encoding ::UTF_8
16
17
OkJson . decode ( string )
17
18
end
18
19
Original file line number Diff line number Diff line change @@ -6,7 +6,12 @@ class JsonTest < ActiveSupport::TestCase
6
6
assert_equal ( { "unicode_example" => "©" } , Spring ::JSON . load ( '{"unicode_example": "\u00A9"}' ) )
7
7
end
8
8
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
+
9
14
test 'can encode' do
10
15
assert_equal ( '{}' , Spring ::JSON . dump ( { } ) )
11
- end
16
+ end
12
17
end
You can’t perform that action at this time.
0 commit comments