From 1725e8afa3df52f1be64c51103398854edfc5912 Mon Sep 17 00:00:00 2001 From: Yang Yan Date: Fri, 1 May 2020 19:13:22 -0600 Subject: [PATCH] Escape special regex characters in library path scan --- src/ui/actions/LibraryActions.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ui/actions/LibraryActions.ts b/src/ui/actions/LibraryActions.ts index e0eb60527..bd199ca64 100644 --- a/src/ui/actions/LibraryActions.ts +++ b/src/ui/actions/LibraryActions.ts @@ -205,7 +205,8 @@ export const add = async (pathsToScan: string[]) => { // 3. Scan all the directories with globby const globbies = folders.map((folder) => { - const pattern = `${folder.replace(/\\/g, '/')}/**/*.*`; + // Normalize slashes and escape regex special characters + const pattern = `${folder.replace(/\\/g, '/').replace(/([$^*+?()\[\]])/g, '\\$1')}/**/*.*`; console.log(pattern); return globby(pattern, { followSymbolicLinks: true });