Encode non conforming chars that break moz-extension urls. Fixes #787

This commit is contained in:
Jonathan Kingston 2017-09-05 13:41:19 -07:00
parent 4ab705081e
commit ad2198e8b5

View file

@ -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) { reloadPageInContainer(url, currentUserContextId, userContextId, index, neverAsk = false) {
const cookieStoreId = backgroundLogic.cookieStoreId(userContextId); const cookieStoreId = backgroundLogic.cookieStoreId(userContextId);
const loadPage = browser.extension.getURL("confirm-page.html"); const loadPage = browser.extension.getURL("confirm-page.html");
@ -336,7 +343,7 @@ const assignManager = {
if (neverAsk) { if (neverAsk) {
browser.tabs.create({url, cookieStoreId, index}); browser.tabs.create({url, cookieStoreId, index});
} else { } else {
let confirmUrl = `${loadPage}?url=${encodeURIComponent(url)}&cookieStoreId=${cookieStoreId}`; let confirmUrl = `${loadPage}?url=${this.encodeURLProperty(url)}&cookieStoreId=${cookieStoreId}`;
let currentCookieStoreId; let currentCookieStoreId;
if (currentUserContextId) { if (currentUserContextId) {
currentCookieStoreId = backgroundLogic.cookieStoreId(currentUserContextId); currentCookieStoreId = backgroundLogic.cookieStoreId(currentUserContextId);