Skip to content

Commit

Permalink
fix parsing of unicode, mixing literal characters with escaped, by fo…
Browse files Browse the repository at this point in the history
…rcing encoding back to ASCII_8BIT before gsubing back into parse_string result
  • Loading branch information
notEthan committed Feb 9, 2022
1 parent 82fe866 commit 766f816
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/json/pure/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def parse_string
bytes << c[6 * i + 2, 2].to_i(16) << c[6 * i + 4, 2].to_i(16)
i += 1
end
JSON.iconv('utf-8', 'utf-16be', bytes)
JSON.iconv('utf-8', 'utf-16be', bytes).force_encoding(::Encoding::ASCII_8BIT)
end
end
if string.respond_to?(:force_encoding)
Expand Down

0 comments on commit 766f816

Please sign in to comment.