diff --git a/src/lib/query.ts b/src/lib/query.ts index 57de991..d2f519e 100644 --- a/src/lib/query.ts +++ b/src/lib/query.ts @@ -30,11 +30,15 @@ export class Query extends BaseQuery { // Validate if input matches any of the safe, pre-approved patterns private isValidRegexPattern(input: string): boolean { + const validRegex = /^[a-zA-Z0-9|^$.*+?()[\]{}\\-]+$/; // Allow only safe regex characters + if (!validRegex.test(input)) { + return false; + } try { - new RegExp(input); // Try to create a new RegExp object - return true; // No error means it's a valid regex + new RegExp(input); + return true; } catch (e) { - return false; // Error means it's not a valid regex + return false; } }