From 9ccfe9f62e69129c41b06c85a3998f70b5c82688 Mon Sep 17 00:00:00 2001 From: girst Date: Fri, 9 Jun 2023 15:35:27 +0200 Subject: [PATCH] fix loading config files under windows windows style paths (backslashes, drive letters) were not handled properly, resulting in NS_ERROR_FILE_UNRECOGNIZED_PATH. --- extension/lib/config.coffee | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/extension/lib/config.coffee b/extension/lib/config.coffee index 220b68c..65658cd 100644 --- a/extension/lib/config.coffee +++ b/extension/lib/config.coffee @@ -30,7 +30,8 @@ load = (vimfx, options = null, callback = ->) -> messageManager.send('loadConfig', null, callback) -checkSandbox = (expandedDir) -> +checkSandbox = (dir) -> + expandedDir = utils.expandPath(dir) prefix = 'security.sandbox.content' if prefs.root.get("#{prefix}.level") > 2 return true @@ -45,13 +46,14 @@ checkSandbox = (expandedDir) -> return not whitelisted.some((e) -> e.startsWith(expandedDir)) loadFile = (dir, file, scope) -> - expandedDir = utils.expandPath(dir) - expandedFile = expandedDir + '/' + file - uri = Services.io.newFileURI(new FileUtils.File(expandedFile)).spec + expandedPath = new FileUtils.File(utils.expandPath(dir)) + dirUri = Services.io.newFileURI(expandedPath).spec + expandedPath.append(file) + uri = Services.io.newFileURI(expandedPath).spec try Services.scriptloader.loadSubScriptWithOptions(uri, { target: Object.assign({ - __dirname: Services.io.newFileURI(new FileUtils.File(expandedDir)).spec, + __dirname: dirUri, Services: Services }, scope) charset: 'UTF-8' @@ -64,7 +66,7 @@ loadFile = (dir, file, scope) -> # without explanation. if typeof error == 'string' and error.startsWith('Error opening input stream (invalid filename?)') and - checkSandbox(expandedDir) + checkSandbox(dir) console.error("VimFx: Error loading #{file} likely due to e10s sandbox") console.info("Please consult VimFx' documentation on config files.") else -- 2.39.3