Skip to content

Commit ad20a99

Browse files
author
DrMyroslav
committed
fix reg for escape
1 parent b8e7da1 commit ad20a99

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

forward_engineering/helpers/general.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const POSTGRES_RESERVED_WORDS = [
9696
'WITH',
9797
];
9898

99-
const MUST_BE_ESCAPED = /'|\\b|\\f|\\n|\\r|\\t|\\o|\\u|\\x|\\$/g;
99+
const MUST_BE_ESCAPED = /\t|\n|'|\f|\r/gm;
100100

101101
module.exports = ({ _, divideIntoActivatedAndDeactivated, commentIfDeactivated }) => {
102102
const getFunctionArguments = functionArguments => {
@@ -182,7 +182,8 @@ module.exports = ({ _, divideIntoActivatedAndDeactivated, commentIfDeactivated }
182182
const prepareComment = (comment = '') =>
183183
comment.replace(MUST_BE_ESCAPED, character => `${'\\'}${character}`);
184184

185-
const wrapComment = comment => `E'${prepareComment(comment)}'`;
185+
186+
const wrapComment = comment => `E'${prepareComment(JSON.stringify(comment)).slice(1, -1)}'`;
186187

187188
return {
188189
getFunctionArguments,

0 commit comments

Comments
 (0)