[ruby/json] Fix generate(script_safe: true) to not confuse unrelated characters
Fix: https://github.com/ruby/json/issues/715 The first byte check was missing. https://github.com/ruby/json/commit/93a7f8717d
This commit is contained in:
parent
4b850ea058
commit
1510d72bec
Notes:
git
2024-12-05 08:16:46 +00:00
@ -155,7 +155,7 @@ static void convert_UTF8_to_JSON(FBuffer *out_buffer, VALUE str, const char esca
|
|||||||
}
|
}
|
||||||
case 3: {
|
case 3: {
|
||||||
unsigned char b2 = ptr[pos + 1];
|
unsigned char b2 = ptr[pos + 1];
|
||||||
if (RB_UNLIKELY(out_script_safe && b2 == 0x80)) {
|
if (RB_UNLIKELY(out_script_safe && ch == 0xE2 && b2 == 0x80)) {
|
||||||
unsigned char b3 = ptr[pos + 2];
|
unsigned char b3 = ptr[pos + 2];
|
||||||
if (b3 == 0xA8) {
|
if (b3 == 0xA8) {
|
||||||
FLUSH_POS(3);
|
FLUSH_POS(3);
|
||||||
|
@ -455,6 +455,10 @@ class JSONGeneratorTest < Test::Unit::TestCase
|
|||||||
data = ["'"]
|
data = ["'"]
|
||||||
json = '["\\\'"]'
|
json = '["\\\'"]'
|
||||||
assert_equal '["\'"]', generate(data)
|
assert_equal '["\'"]', generate(data)
|
||||||
|
#
|
||||||
|
data = ["倩", "瀨"]
|
||||||
|
json = '["倩","瀨"]'
|
||||||
|
assert_equal json, generate(data, script_safe: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_string_subclass
|
def test_string_subclass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user