Don't even block submit function with synchronous XmlHttpRequest

Enable wildcard for one level domains
This commit is contained in:
Grégory Soutadé 2014-02-27 18:35:25 +01:00
parent 61828b741d
commit cbeb7e3d73
2 changed files with 15 additions and 8 deletions

View File

@ -66,7 +66,7 @@ function generate_request(domain, login, mkey)
return enc; return enc;
} }
function ask_server(field, logins, domain, wdomain, mkey, salt) function ask_server(form, field, logins, domain, wdomain, mkey, salt)
{ {
mkey = pkdbf2.pkdbf2(mkey, salt, pkdbf2_level, 256/8); mkey = pkdbf2.pkdbf2(mkey, salt, pkdbf2_level, 256/8);
@ -203,6 +203,9 @@ function ask_server(field, logins, domain, wdomain, mkey, salt)
clear_password = clear_password.substr(0, clear_password.length-3); clear_password = clear_password.substr(0, clear_password.length-3);
debug("Clear password " + clear_password); debug("Clear password " + clear_password);
field.value = clear_password; field.value = clear_password;
// Remove gPass event listener and submit again with clear password
form.removeEventListener("submit", on_sumbit, true);
form.submit();
} }
else else
{ {
@ -228,7 +231,7 @@ function ask_server(field, logins, domain, wdomain, mkey, salt)
}, false); }, false);
debug("connect to " + prefSet.prefs.account_url); debug("connect to " + prefSet.prefs.account_url);
gPassRequest.open("POST", prefSet.prefs.account_url, false); gPassRequest.open("POST", prefSet.prefs.account_url, true);
gPassRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); gPassRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
gPassRequest.send(keys); gPassRequest.send(keys);
@ -251,6 +254,9 @@ function wildcard_domain(domain)
else else
return "*" + "." + parts[parts.length-2] + "." + parts[parts.length-1]; return "*" + "." + parts[parts.length-2] + "." + parts[parts.length-1];
} }
// Simple xxx.com
else if (parts.length == 2)
return "*" + "." + parts[0] + "." + parts[1];
return ""; return "";
} }
@ -310,18 +316,19 @@ function on_sumbit(e)
mkey = password.substring(2); mkey = password.substring(2);
var ret = ask_server(field, logins, domain, wdomain, mkey, salt); var ret = ask_server(form, field, logins, domain, wdomain, mkey, salt);
switch(ret) switch(ret)
{ {
case SERVER.OK: case SERVER.OK:
return true; e.preventDefault();
break;
case SERVER.FAILED: case SERVER.FAILED:
if (logins !== all_logins) if (logins !== all_logins)
{ {
ret = ask_server(field, all_logins, domain, wdomain, mkey, salt); ret = ask_server(form, field, all_logins, domain, wdomain, mkey, salt);
if (ret == SERVER.OK) if (ret == SERVER.OK)
return true; break;
} }
e.preventDefault(); e.preventDefault();
break; break;
@ -332,7 +339,7 @@ function on_sumbit(e)
} }
} }
return true; return false;
} }
function document_loaded(event) function document_loaded(event)

View File

@ -5,7 +5,7 @@
"description": "gPass : global password manager", "description": "gPass : global password manager",
"author": "Grégory Soutadé", "author": "Grégory Soutadé",
"license": "GNU GPL v3", "license": "GNU GPL v3",
"version": "0.3", "version": "0.4",
"preferences": [ "preferences": [
{ {
"name": "account_url", "name": "account_url",