Browse Source

fix: sanitise / unsanitise strings only

pull/2535/head
Wing-Kam Wong 2 years ago
parent
commit
671ad68171
  1. 2
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/helpers/sanitize.ts

2
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/helpers/sanitize.ts

@ -1,9 +1,11 @@
export function sanitize(v) { export function sanitize(v) {
if (typeof v !== 'string') return v;
return v?.replace(/([^\\]|^)(\?+)/g, (_, m1, m2) => { return v?.replace(/([^\\]|^)(\?+)/g, (_, m1, m2) => {
return `${m1}${m2.split('?').join('\\?')}`; return `${m1}${m2.split('?').join('\\?')}`;
}); });
} }
export function unsanitize(v) { export function unsanitize(v) {
if (typeof v !== 'string') return v;
return v?.replace(/\\[?]/g, '?'); return v?.replace(/\\[?]/g, '?');
} }

Loading…
Cancel
Save