mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 01:51:40 -05:00
Merge pull request #1402 from glacambre/fix_windows_nativeopen_escaping
excmds.ts: Fix nativeopen using wrong escaping scheme on windows
This commit is contained in:
commit
31e4777296
1 changed files with 13 additions and 1 deletions
|
@ -517,7 +517,19 @@ export async function nativeopen(...args: string[]) {
|
||||||
}
|
}
|
||||||
firefoxArgs.push("--new-tab")
|
firefoxArgs.push("--new-tab")
|
||||||
}
|
}
|
||||||
await Native.run(`${config.get("browser")} ${firefoxArgs.join(" ")} '${url.replace(/'/g, "'\\''")}'`)
|
let escapedUrl = url
|
||||||
|
// On linux, we need to quote and escape single quotes in the
|
||||||
|
// url, otherwise an attacker could create an anchor with a url
|
||||||
|
// like 'file:// && $(touch /tmp/dead)' and achieve remote code
|
||||||
|
// execution when the user tries to follow it with `hint -W tabopen`
|
||||||
|
// But windows treats single quotes as "open this file from the
|
||||||
|
// user's directory", so we need to use double quotes there
|
||||||
|
if ((await browser.runtime.getPlatformInfo()).os === "win") {
|
||||||
|
escapedUrl = `"${escapedUrl.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`
|
||||||
|
} else {
|
||||||
|
escapedUrl = `'${escapedUrl.replace(/'/g, `'"'"'`)}'`
|
||||||
|
}
|
||||||
|
await Native.run(`${config.get("browser")} ${firefoxArgs.join(" ")} ${escapedUrl}`)
|
||||||
}
|
}
|
||||||
setTimeout(() => browser.tabs.onCreated.removeListener(selecttab), 100)
|
setTimeout(() => browser.tabs.onCreated.removeListener(selecttab), 100)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue