Skip to content

Commit 399e538

Browse files
committed
sanitize idb dynamic import url
AMO moment...
1 parent 133fde1 commit 399e538

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/content-script.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
(() => {
22
window.__securlyPlusLoad = async loadedData => {
33
data = loadedData;
4-
// load idb
5-
idb = await import(data.idbUrl);
4+
// load idb (but sanitize the URL first)
5+
const idbUrl = data.idbUrl.match(/^(moz|chrome)-extension:\/\/([\w-]+)\/idb.js$/);
6+
if (!idbUrl) throw new Error("invalid IDB url");
7+
idb = await import(`${idbUrl[1]}-extension://${idbUrl[2]}/idb.js`);
68
db = await idb.openDB("__securly-plus-db", 2, {
79
upgrade(db, oldVersion) {
810
if (oldVersion < 1) {

0 commit comments

Comments
 (0)