1
1
mirror of https://github.com/Fabio286/antares.git synced 2024-12-25 16:22:38 +01:00

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

View File

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