Remove block_url feature to increase websites compatibility

This commit is contained in:
Grégory Soutadé 2020-08-29 17:57:39 +02:00
parent 630a3f9cb9
commit 90e9862982
8 changed files with 2 additions and 206 deletions

View File

@ -216,47 +216,6 @@ async function ask_server(logins, domain, wdomain, mkey, sendResponse, options)
return true; return true;
} }
function url_block_callback(details)
{
// debug(JSON.stringify(details));
if (details.requestBody)
{
if (details.requestBody.formData)
{
for (var key in details.requestBody.formData)
{
for(var idx in details.requestBody.formData[key])
{
value = details.requestBody.formData[key][idx];
if (value.startsWith("@@") ||
value.startsWith("@_"))
return {cancel: true};
}
}
}
/*
// Analyse POST parameters
if (details.method == "POST" && details.requestBody.raw)
{
alert(details.requestBody.raw);
var postedString = decodeURIComponent(String.fromCharCode.apply(null,
new Uint8Array(details.requestBody.raw[0].bytes)));
if (postedString.indexOf("=@@") != -1 ||
postedString.indexOf("=@_") != -1)
return {cancel: true};
}
*/
}
return {cancel: false};
}
function url_unblock_callback(details)
{
return {cancel: false};
}
function update_gpass_icon(iconId, tabId) function update_gpass_icon(iconId, tabId)
{ {
debug("update_gpass_icon"); debug("update_gpass_icon");
@ -312,38 +271,6 @@ function save_gpass_enable_config(uri, enable)
} }
} }
function _block_url(tabs, callback)
{
options = {
urls:[tabs[0].url],
"types":["main_frame"]
};
if (tabs.length)
{
options["tabId"] = tabs[0].id;
options["windowId"] = tabs[0].windowId;
}
browser.webRequest.onBeforeRequest.addListener(
url_block_callback,
options,
["blocking", "requestBody"]);
return true;
}
function _query_tabs_block_url(tabs)
{
return _block_url(tabs, url_block_callback);
}
function _query_tabs_unblock_url(tabs)
{
return _block_url(tabs, url_unblock_callback);
}
function _query_tabs_is_gpass_enabled(tabs, sendResponse) function _query_tabs_is_gpass_enabled(tabs, sendResponse)
{ {
if (tabs.length) if (tabs.length)
@ -426,14 +353,6 @@ function extension_load()
}); });
return true; return true;
} }
else if (request.type == "block_url")
{
browser.tabs.query({active:true, currentWindow:true}, _query_tabs_block_url);
}
else if (request.type == "unblock_url")
{
browser.tabs.query({active:true, currentWindow:true}, _query_tabs_unblock_url);
}
else if (request.type == "is_gpass_enabled") else if (request.type == "is_gpass_enabled")
{ {
browser.tabs.query({active:true, currentWindow:true}, browser.tabs.query({active:true, currentWindow:true},

View File

@ -236,7 +236,6 @@ function block_all_forms(doc, do_block)
{ {
if (do_block) if (do_block)
{ {
block_url(form.action);
old_cb = form.onsubmit; old_cb = form.onsubmit;
if (old_cb) if (old_cb)
form.removeEventListener("submit", old_cb); form.removeEventListener("submit", old_cb);
@ -254,10 +253,6 @@ function block_all_forms(doc, do_block)
} }
} }
} }
/* Request can be sent to another URL... */
if (managed_forms.length && do_block)
block_url("<all_urls>");
} }
function unblock_all_forms() function unblock_all_forms()
@ -271,7 +266,6 @@ function unblock_all_forms()
var form = managed_forms[i]; var form = managed_forms[i];
form.removeEventListener("submit", on_sumbit); form.removeEventListener("submit", on_sumbit);
unblock_url(form.action);
var fields = form.getElementsByTagName("input"); var fields = form.getElementsByTagName("input");
for (var a=0; a<fields.length; a++) for (var a=0; a<fields.length; a++)
@ -286,9 +280,6 @@ function unblock_all_forms()
} }
} }
if (managed_forms.length)
unblock_url("<all_urls>");
gpass_enabled = false; gpass_enabled = false;
} }

View File

@ -34,18 +34,6 @@ function notify(text, data)
browser.runtime.sendMessage({type: "notification", options:{"message":text, "data":data}}); browser.runtime.sendMessage({type: "notification", options:{"message":text, "data":data}});
} }
function block_url(url)
{
debug("Block URL " + url);
browser.runtime.sendMessage({type: "block_url", options:{"url":url}});
}
function unblock_url(url)
{
debug("Unblock URL " + url);
browser.runtime.sendMessage({type: "unblock_url", options:{"url":url}});
}
// https://stackoverflow.com/questions/6965107/converting-between-strings-and-arraybuffers // https://stackoverflow.com/questions/6965107/converting-between-strings-and-arraybuffers
function ab2str(buf) { function ab2str(buf) {
return String.fromCharCode.apply(null, new Uint8Array(buf)); return String.fromCharCode.apply(null, new Uint8Array(buf));

View File

@ -3,7 +3,7 @@
"name": "gPass", "name": "gPass",
"short_name": "gPass", "short_name": "gPass",
"version": "0.9", "version": "1.0",
"description": "gPass : global password manager", "description": "gPass : global password manager",
"icons" : {"16":"icons/gpass_icon_16.png", "32":"icons/gpass_icon_32.png", "64":"icons/gpass_icon_64.png", "128":"icons/gpass_icon_128.png"}, "icons" : {"16":"icons/gpass_icon_16.png", "32":"icons/gpass_icon_32.png", "64":"icons/gpass_icon_64.png", "128":"icons/gpass_icon_128.png"},
"author" : "Grégory Soutadé", "author" : "Grégory Soutadé",

View File

@ -216,47 +216,6 @@ async function ask_server(logins, domain, wdomain, mkey, sendResponse, options)
return true; return true;
} }
function url_block_callback(details)
{
// debug(JSON.stringify(details));
if (details.requestBody)
{
if (details.requestBody.formData)
{
for (var key in details.requestBody.formData)
{
for(var idx in details.requestBody.formData[key])
{
value = details.requestBody.formData[key][idx];
if (value.startsWith("@@") ||
value.startsWith("@_"))
return {cancel: true};
}
}
}
/*
// Analyse POST parameters
if (details.method == "POST" && details.requestBody.raw)
{
alert(details.requestBody.raw);
var postedString = decodeURIComponent(String.fromCharCode.apply(null,
new Uint8Array(details.requestBody.raw[0].bytes)));
if (postedString.indexOf("=@@") != -1 ||
postedString.indexOf("=@_") != -1)
return {cancel: true};
}
*/
}
return {cancel: false};
}
function url_unblock_callback(details)
{
return {cancel: false};
}
function update_gpass_icon(iconId, tabId) function update_gpass_icon(iconId, tabId)
{ {
debug("update_gpass_icon"); debug("update_gpass_icon");
@ -312,38 +271,6 @@ function save_gpass_enable_config(uri, enable)
} }
} }
function _block_url(tabs, callback)
{
options = {
urls:[tabs[0].url],
"types":["main_frame"]
};
if (tabs.length)
{
options["tabId"] = tabs[0].id;
options["windowId"] = tabs[0].windowId;
}
browser.webRequest.onBeforeRequest.addListener(
url_block_callback,
options,
["blocking", "requestBody"]);
return true;
}
function _query_tabs_block_url(tabs)
{
return _block_url(tabs, url_block_callback);
}
function _query_tabs_unblock_url(tabs)
{
return _block_url(tabs, url_unblock_callback);
}
function _query_tabs_is_gpass_enabled(tabs, sendResponse) function _query_tabs_is_gpass_enabled(tabs, sendResponse)
{ {
if (tabs.length) if (tabs.length)
@ -426,14 +353,6 @@ function extension_load()
}); });
return true; return true;
} }
else if (request.type == "block_url")
{
browser.tabs.query({active:true, currentWindow:true}, _query_tabs_block_url);
}
else if (request.type == "unblock_url")
{
browser.tabs.query({active:true, currentWindow:true}, _query_tabs_unblock_url);
}
else if (request.type == "is_gpass_enabled") else if (request.type == "is_gpass_enabled")
{ {
browser.tabs.query({active:true, currentWindow:true}, browser.tabs.query({active:true, currentWindow:true},

View File

@ -236,7 +236,6 @@ function block_all_forms(doc, do_block)
{ {
if (do_block) if (do_block)
{ {
block_url(form.action);
old_cb = form.onsubmit; old_cb = form.onsubmit;
if (old_cb) if (old_cb)
form.removeEventListener("submit", old_cb); form.removeEventListener("submit", old_cb);
@ -254,10 +253,6 @@ function block_all_forms(doc, do_block)
} }
} }
} }
/* Request can be sent to another URL... */
if (managed_forms.length && do_block)
block_url("<all_urls>");
} }
function unblock_all_forms() function unblock_all_forms()
@ -271,7 +266,6 @@ function unblock_all_forms()
var form = managed_forms[i]; var form = managed_forms[i];
form.removeEventListener("submit", on_sumbit); form.removeEventListener("submit", on_sumbit);
unblock_url(form.action);
var fields = form.getElementsByTagName("input"); var fields = form.getElementsByTagName("input");
for (var a=0; a<fields.length; a++) for (var a=0; a<fields.length; a++)
@ -286,9 +280,6 @@ function unblock_all_forms()
} }
} }
if (managed_forms.length)
unblock_url("<all_urls>");
gpass_enabled = false; gpass_enabled = false;
} }

View File

@ -34,18 +34,6 @@ function notify(text, data)
browser.runtime.sendMessage({type: "notification", options:{"message":text, "data":data}}); browser.runtime.sendMessage({type: "notification", options:{"message":text, "data":data}});
} }
function block_url(url)
{
debug("Block URL " + url);
browser.runtime.sendMessage({type: "block_url", options:{"url":url}});
}
function unblock_url(url)
{
debug("Unblock URL " + url);
browser.runtime.sendMessage({type: "unblock_url", options:{"url":url}});
}
// https://stackoverflow.com/questions/6965107/converting-between-strings-and-arraybuffers // https://stackoverflow.com/questions/6965107/converting-between-strings-and-arraybuffers
function ab2str(buf) { function ab2str(buf) {
return String.fromCharCode.apply(null, new Uint8Array(buf)); return String.fromCharCode.apply(null, new Uint8Array(buf));

View File

@ -3,7 +3,7 @@
"name": "gPass", "name": "gPass",
"short_name": "gPass", "short_name": "gPass",
"version": "0.9", "version": "1.0",
"description": "gPass : global password manager", "description": "gPass : global password manager",
"icons" : {"16":"icons/gpass_icon_16.png", "32":"icons/gpass_icon_32.png", "64":"icons/gpass_icon_64.png", "128":"icons/gpass_icon_128.png"}, "icons" : {"16":"icons/gpass_icon_16.png", "32":"icons/gpass_icon_32.png", "64":"icons/gpass_icon_64.png", "128":"icons/gpass_icon_128.png"},
"author" : "Grégory Soutadé", "author" : "Grégory Soutadé",