fix escaping bug with backslashes
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
JSONString
|
JSONString
|
||||||
: STRING
|
: STRING
|
||||||
{$$ = yytext;}
|
{$$ = yytext.replace(/\\\\/g, "\\");}
|
||||||
;
|
;
|
||||||
|
|
||||||
JSONNumber
|
JSONNumber
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ exports["test object"] = function () {
|
|||||||
assert.deepEqual(parser.parse(json), {"foo": "bar"});
|
assert.deepEqual(parser.parse(json), {"foo": "bar"});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports["test escaped backslash"] = function () {
|
||||||
|
var json = '{"foo": "\\\\"}';
|
||||||
|
assert.deepEqual(parser.parse(json), {"foo": "\\"});
|
||||||
|
};
|
||||||
|
|
||||||
exports["test string with escaped line break"] = function () {
|
exports["test string with escaped line break"] = function () {
|
||||||
var json = '{"foo": "bar\\nbar"}';
|
var json = '{"foo": "bar\\nbar"}';
|
||||||
assert.deepEqual(parser.parse(json), {"foo": "bar\\nbar"});
|
assert.deepEqual(parser.parse(json), {"foo": "bar\\nbar"});
|
||||||
|
|||||||
Reference in New Issue
Block a user