Project

General

Profile

Actions

Bug #6566

closed

JSON.dump can generate invalid UTF-8 sequence

Added by shyouhei (Shyouhei Urabe) almost 12 years ago. Updated over 4 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.0.0dev (2012-06-09) [x86_64-linux]
[ruby-core:45535]

Description

=begin
Look, in the following code JSON.dump outputs a sequence invalid as UTF-8.

-- encoding: utf-8 --

require 'json'
IO.popen('hexdump -C', 'w') do |fp|
JSON.dump(["\xea"], fp)
end

RFC4627 says that to encode JSON as a Unicode is a "SHALL". So this is an RFC violation.

=end


Files

bug-6566.diff (1.62 KB) bug-6566.diff reject invalid UTF-8 sequence in JSON.generate nobu (Nobuyoshi Nakada), 06/10/2012 07:19 AM

Updated by nobu (Nobuyoshi Nakada) almost 12 years ago

=begin
A bit simpler, it seems wrong that
JSON.generate(["\xea"]).valid_encoding?
returns (({false})).

I think this would be a bug in json generator, but what should happen
in this case? Seems (({convert_UTF8_to_JSON_ASCII()})) wants to reject
invalid sequence.
=end

Updated by naruse (Yui NARUSE) almost 12 years ago

json is not only for 1.9, so nobu's patch is not acceptable.
I made https://github.com/flori/json/pull/139 .

Updated by naruse (Yui NARUSE) about 11 years ago

  • Target version changed from 2.0.0 to 2.6
Actions #4

Updated by naruse (Yui NARUSE) over 6 years ago

  • Target version deleted (2.6)

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

  • Status changed from Assigned to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0