MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / safeRegexTest

Function safeRegexTest

packages/agentflow/src/core/utils/fieldVisibility.ts:50–58  ·  view source on GitHub ↗

* Safe regex test: rejects patterns that are oversized, contain nested quantifiers * (the primary cause of catastrophic backtracking), or are syntactically invalid.

(pattern: string, value: string)

Source from the content-addressed store, hash-verified

48 * (the primary cause of catastrophic backtracking), or are syntactically invalid.
49 */
50function safeRegexTest(pattern: string, value: string): boolean {
51 if (pattern.length > MAX_REGEX_LENGTH) return false
52 if (hasNestedQuantifier(pattern)) return false
53 try {
54 return new RegExp(pattern).test(value)
55 } catch {
56 return false
57 }
58}
59
60/**
61 * Check if a ground value matches a comparison value using the same matrix

Callers 1

conditionMatchesFunction · 0.85

Calls 2

hasNestedQuantifierFunction · 0.85
testMethod · 0.80

Tested by

no test coverage detected