fix: sqlEscaper function wrong quotes conversion

This commit is contained in:
Fabio Di Stasio 2020-11-20 09:16:18 +01:00
parent 0fe71572a5
commit dfb24c65f3
1 changed files with 2 additions and 2 deletions

View File

@ -11,8 +11,8 @@ const regex = new RegExp(pattern);
*/
function sqlEscaper (string) {
return string.replace(regex, char => {
const m = ['\\0', '\\x08', '\\x09', '\\x1a', '\\n', '\\r', '\'', '"', '\\', '\\\\', '%'];
const r = ['\\\\0', '\\\\b', '\\\\t', '\\\\z', '\\\\n', '\\\\r', '\'\'', '""', '\\\\', '\\\\\\\\', '\\%'];
const m = ['\\0', '\\x08', '\\x09', '\\x1a', '\\n', '\\r', '\'', '\"', '\\', '\\\\', '%'];
const r = ['\\\\0', '\\\\b', '\\\\t', '\\\\z', '\\\\n', '\\\\r', '\\\'', '\\\"', '\\\\', '\\\\\\\\', '\\%'];
return r[m.indexOf(char)] || char;
});
}