Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: handle vertical tab escaping #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions test/test-parse-verticaltab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

const yj = require('../index');
const tap = require('tap');

//string with nested quotes
const str = '{"name":"Ila Gould","age":22,"gender":"female","nested":"\\u000bcheck"}';

yj.parseAsync(str, (error, obj) => {
if (!error){
tap.equal(str,JSON.stringify(obj));
yj.stringifyAsync(obj,(err,data) => {
if(!err){
tap.equal(data,str);
}
else
tap.fail(err);
})
}
else
tap.fail(error);
});
27 changes: 27 additions & 0 deletions test/test-stringify-verticaltab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';

const yj = require('../index');
const tap = require('tap');

//Object with nested quotes
const obj = {
name: 'Jacqueline Poole',
gender: 'female',
age: 40,
a:"\vb"
};

yj.stringifyAsync(obj, (err, str) => {
if (!err){
tap.equal(JSON.stringify(obj), str);
yj.parseAsync(str,(error,data) => {
if(!error){
tap.same(data,obj);
}
else
tap.fail(error);
})
}
else
tap.fail(err);
});
1 change: 1 addition & 0 deletions yieldable-stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ let normalize = (string, flagN) => {
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'\v': '\\u000b',
'"': '\\"',
};
// Escape is implemented globally
Expand Down