mirror of
https://github.com/appy-one/acebase.git
synced 2026-06-30 06:02:02 -06:00
Fix escaping of all control chars in exportNode
This commit is contained in:
parent
974b08c9a3
commit
bc3d77c422
1 changed files with 10 additions and 1 deletions
|
|
@ -1624,7 +1624,16 @@ export class Storage extends SimpleEventEmitter {
|
|||
: writeFn;
|
||||
|
||||
const stringifyValue = (type: number, val: any) => {
|
||||
const escape = (str: string) => str.replace(/"/g, '\\"').replace(/\n/g, '\\n');
|
||||
const escape = (str: string) => str
|
||||
.replace(/\\/g, '\\\\') // forward slashes
|
||||
.replace(/"/g, '\\"') // quotes
|
||||
.replace(/\r/g, '\\r') // carriage return
|
||||
.replace(/\n/g, '\\n') // line feed
|
||||
.replace(/\t/g, '\\t') // tabs
|
||||
.replace(/[\u0000-\u001f]/g, // other control characters
|
||||
ch => `\\u${ch.charCodeAt(0).toString(16).padStart(4, '0')}`
|
||||
);
|
||||
|
||||
if (type === VALUE_TYPES.DATETIME) {
|
||||
val = `"${val.toISOString()}"`;
|
||||
if (options.type_safe) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue