From ad2198e8b55319fb38fa4287ba22aee593fa60cb Mon Sep 17 00:00:00 2001 From: Jonathan Kingston Date: Tue, 5 Sep 2017 13:41:19 -0700 Subject: [PATCH] Encode non conforming chars that break moz-extension urls. Fixes #787 --- webextension/js/background/assignManager.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/webextension/js/background/assignManager.js b/webextension/js/background/assignManager.js index 2a1ad65..315b0de 100644 --- a/webextension/js/background/assignManager.js +++ b/webextension/js/background/assignManager.js @@ -328,6 +328,13 @@ const assignManager = { }); }, + encodeURLProperty(url) { + return encodeURIComponent(url).replace(/[!'()*]/g, (c) => { + const charCode = c.charCodeAt(0).toString(16); + return `%${charCode}`; + }); + }, + reloadPageInContainer(url, currentUserContextId, userContextId, index, neverAsk = false) { const cookieStoreId = backgroundLogic.cookieStoreId(userContextId); const loadPage = browser.extension.getURL("confirm-page.html"); @@ -336,7 +343,7 @@ const assignManager = { if (neverAsk) { browser.tabs.create({url, cookieStoreId, index}); } else { - let confirmUrl = `${loadPage}?url=${encodeURIComponent(url)}&cookieStoreId=${cookieStoreId}`; + let confirmUrl = `${loadPage}?url=${this.encodeURLProperty(url)}&cookieStoreId=${cookieStoreId}`; let currentCookieStoreId; if (currentUserContextId) { currentCookieStoreId = backgroundLogic.cookieStoreId(currentUserContextId);