Skip to content

Commit 90e360b

Browse files
committed
fix: import a plugin from manifest.json. Closes #358
1 parent 21a518c commit 90e360b

2 files changed

Lines changed: 2 additions & 18 deletions

File tree

src/main/ExtensionManager.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { dialogs } from "./Dialogs";
88
import { storage } from "Storage";
99
import { logger } from "./Logger";
1010
import { FILE_EXTENSION_WHITE_LIST, FILE_WHITE_LIST, MANIFEST_FILE_NAME } from "Const";
11-
import { ALLOW_CODE_FILES, ALLOW_EXT_FILES, ALLOW_UI_FILES, sanitizeFileName } from "Utils/Common";
11+
import { ALLOW_CODE_FILES, ALLOW_EXT_FILES, ALLOW_UI_FILES } from "Utils/Common";
1212
import { access, mkPath } from "Utils/Main";
1313

1414
type ObserverCallback = (args: any) => void;
@@ -438,8 +438,7 @@ export default class ExtensionManager {
438438
if (
439439
!FILE_WHITE_LIST.includes(file.name) &&
440440
(!FILE_EXTENSION_WHITE_LIST.includes(extname(file.name)) ||
441-
!/^[\w/]+(?:\.\w+)*\.\w+/.test(file.name) ||
442-
file.name !== sanitizeFileName(file.name))
441+
!/^[\w/]+(?:\.\w+)*\.\w+/.test(file.name))
443442
) {
444443
throw new Error(`Filename "${file.name}" not allowed`);
445444
}

src/utils/Common/extensions.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
11
export const ALLOW_EXT_FILES = /^(.+\.(html|js|ts)|manifest.json)$/;
22
export const ALLOW_CODE_FILES = /^(.+\.(js|ts))$/;
33
export const ALLOW_UI_FILES = /^(.+\.html)$/;
4-
5-
export function sanitizeFileName(input: string): string {
6-
const illegalRe = /[\/\?<>\\:\*\|":]/g;
7-
const controlRe = /[\x00-\x1f\x80-\x9f]/g;
8-
const reservedRe = /^\.+$/;
9-
const windowsReservedRe = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i;
10-
const windowsTrailingRe = /[\. ]+$/;
11-
12-
return input
13-
.replace(illegalRe, "")
14-
.replace(controlRe, "")
15-
.replace(reservedRe, "")
16-
.replace(windowsReservedRe, "")
17-
.replace(windowsTrailingRe, "");
18-
}

0 commit comments

Comments
 (0)