π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
escape needle
Fendy Heryanto21e49670ac3e
diff --git a/packages/nocodb-sdk/src/lib/formula/handle-formula-error.ts b/packages/nocodb-sdk/src/lib/formula/handle-formula-error.tsindex ffbd1fb05d..58e02bcb85 100644--- a/packages/nocodb-sdk/src/lib/formula/handle-formula-error.ts+++ b/packages/nocodb-sdk/src/lib/formula/handle-formula-error.ts@@ -1,4 +1,7 @@-import { getRowColPositionFromIndex } from '~/lib/stringHelpers';+import {+ escapeRegexString,+ getRowColPositionFromIndex,+} from '~/lib/stringHelpers';import { FormulaError } from './error';import { FormulaErrorType } from './enums';const REGEX_ERROR_AT_CHARACTER = /\sat character (\d+)/;@@ -17,7 +20,10 @@ export function handleFormulaError({identifierLength = error.extra.position.length;} else if (error.extra?.columnName ?? error.extra?.calleeName) {const needle = error.extra?.columnName ?? error.extra?.calleeName;- const identifierMatch = formula.match(new RegExp(`\\b${needle}\\b`));++ const identifierMatch = formula.match(+ new RegExp(`\\b${escapeRegexString(needle)}\\b`)+ );if (typeof identifierMatch?.index === 'number') {position = identifierMatch.index;identifierLength = needle.length;diff --git a/packages/nocodb-sdk/src/lib/stringHelpers.ts b/packages/nocodb-sdk/src/lib/stringHelpers.tsindex e891b43d05..35ddde8e88 100644--- a/packages/nocodb-sdk/src/lib/stringHelpers.ts+++ b/packages/nocodb-sdk/src/lib/stringHelpers.ts@@ -147,3 +147,7 @@ export function generateUniqueCopyName<T = string>(return newName;}++export function escapeRegexString(string: string) {+ return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');+}