From a23b4a4b361c4940160e2a26160de342e82f6300 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Sun, 8 Jan 2023 20:32:17 +0900 Subject: [PATCH] (partially) cherry-picked from misskey/10e526b fix: Escape SQL LIKE * SQL LIKE escape * CHANGELOG --- packages/backend/src/misc/sql-like-escape.ts | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 packages/backend/src/misc/sql-like-escape.ts diff --git a/packages/backend/src/misc/sql-like-escape.ts b/packages/backend/src/misc/sql-like-escape.ts new file mode 100644 index 000000000..8470dca3d --- /dev/null +++ b/packages/backend/src/misc/sql-like-escape.ts @@ -0,0 +1,3 @@ +export function sqlLikeEscape(s: string) { + return s.replace(/([%_])/g, '\\$1'); +}