Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/lib/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
Loading