Skip to content

Commit

Permalink
fix: fix Regular expression injection
Browse files Browse the repository at this point in the history
  • Loading branch information
leonid committed Dec 17, 2024
1 parent 797dca2 commit ebea29a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/ui/scripts/utils/fuzzyMatch.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { escapeRegExp } from 'lodash-es';

export function fuzzyMatch(partials: string[], total: string[], includeAll = false) {
const matched: string[] = [];

partials.forEach((partial) => {
const safePartial = escapeRegExp(partial);

for (const target of total) {
if (target.match(partial)) {
if (target.match(safePartial)) {
matched.push(target);

if (!includeAll) {
Expand Down

0 comments on commit ebea29a

Please sign in to comment.