mirror of
https://github.com/Fabio286/antares.git
synced 2025-04-24 23:08:42 +02:00
fix: newline replaced with undefined inside queries
This commit is contained in:
parent
7bc10092fe
commit
59e4a79f42
@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable no-useless-escape */
|
/* eslint-disable no-useless-escape */
|
||||||
// eslint-disable-next-line no-control-regex
|
// eslint-disable-next-line no-control-regex
|
||||||
const regex = new RegExp(/[\0\x08\x09\x1a\n\r"'\\\%]/g);
|
const regex = new RegExp(/[\0\x08\x09\x1a\n\r"'\\\%]/gm);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Escapes a string
|
* Escapes a string
|
||||||
@ -9,10 +9,10 @@ const regex = new RegExp(/[\0\x08\x09\x1a\n\r"'\\\%]/g);
|
|||||||
* @returns {String}
|
* @returns {String}
|
||||||
*/
|
*/
|
||||||
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)];
|
return r[m.indexOf(char)] || char;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user