Merge branch 'master' of soutade.fr:gpass

This commit is contained in:
Gregory Soutade 2015-12-04 17:03:16 +01:00
commit ba75b73503
5 changed files with 112 additions and 55 deletions

View File

@ -265,6 +265,48 @@ function wildcard_domain(domain)
return "";
}
function _add_name(logins, name)
{
for(var i=0; i<logins.length; i++)
if (logins[i] == name) return ;
logins.push(name);
}
function try_get_name(fields, type_filters, match)
{
var user = null;
var all_logins = new Array();
for (var i=0; i<fields.length; i++)
{
var field = fields[i];
for (var a=0; a<type_filters.length; a++)
{
if ((match && field.getAttribute("type") == type_filters[a]) ||
(!match && field.getAttribute("type") != type_filters[a]))
{
if (field.hasAttribute("name") && field.value != "")
{
name = field.getAttribute("name");
// Subset of common user field
if (name == "user") user = field.value;
else if (name == "usr") user = field.value;
else if (name == "username") user = field.value;
else if (name == "login") user = field.value;
_add_name(all_logins, field.value);
}
}
}
}
if (user != null)
return new Array(user);
else
return all_logins;
}
function on_sumbit(e)
{
var form = this;
@ -279,32 +321,18 @@ function on_sumbit(e)
debug("salt " + salt);
var user = null;
var all_logins = new Array();
type_filters = new Array();
// Get all <input type="text"> && <input type="email">
for (var i=0; i<fields.length; i++)
{
var field = fields[i];
if (field.getAttribute("type") == "text" || field.getAttribute("type") == "email")
{
if (field.hasAttribute("name") && field.value != "")
{
name = field.getAttribute("name");
// Subset of common user field
if (name == "user") user = field.value;
else if (name == "usr") user = field.value;
else if (name == "username") user = field.value;
else if (name == "login") user = field.value;
all_logins.push(field.value);
}
}
}
type_filters.push("text");
type_filters.push("email");
logins = try_get_name(fields, type_filters, true);
if (user != null)
logins = new Array(user);
else
logins = all_logins;
// Get all other fields except text, email and password
if (!logins.length)
{
type_filters.push("password");
logins = try_get_name(fields, type_filters, false);
}
// Look for <input type="password" value="@@...">
for (var i=0; i<fields.length; i++)

View File

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

View File

@ -22,9 +22,9 @@ var notifications = require("sdk/notifications");
var self = require("sdk/self");
var prefSet = require("sdk/simple-prefs");
var pkdbf2 = require("pkdbf2").pkdbf2;
var aes = require("jsaes").aes;
var parseURI = require("parseuri").parseURI;
var pkdbf2 = require("lib/pkdbf2").pkdbf2;
var aes = require("lib/jsaes").aes;
var parseURI = require("lib/parseuri").parseURI;
var DEBUG = false;
var pkdbf2_level = getPref("pkdbf2_level");
var protocol_version = 3;
@ -272,6 +272,48 @@ function wildcard_domain(domain)
return "";
}
function _add_name(logins, name)
{
for(var i=0; i<logins.length; i++)
if (logins[i] == name) return ;
logins.push(name);
}
function try_get_name(fields, type_filters, match)
{
var user = null;
var all_logins = new Array();
for (var i=0; i<fields.length; i++)
{
var field = fields[i];
for (var a=0; a<type_filters.length; a++)
{
if ((match && field.getAttribute("type") == type_filters[a]) ||
(!match && field.getAttribute("type") != type_filters[a]))
{
if (field.hasAttribute("name") && field.value != "")
{
name = field.getAttribute("name");
// Subset of common user field
if (name == "user") user = field.value;
else if (name == "usr") user = field.value;
else if (name == "username") user = field.value;
else if (name == "login") user = field.value;
_add_name(all_logins, field.value);
}
}
}
}
if (user != null)
return new Array(user);
else
return all_logins;
}
function on_sumbit(e)
{
var form = this;
@ -286,32 +328,18 @@ function on_sumbit(e)
debug("salt " + salt);
var user = null;
var all_logins = new Array();
type_filters = new Array();
// Get all <input type="text"> && <input type="email">
for (var i=0; i<fields.length; i++)
{
var field = fields[i];
if (field.getAttribute("type") == "text" || field.getAttribute("type") == "email")
{
if (field.hasAttribute("name") && field.value != "")
{
name = field.getAttribute("name");
// Subset of common user field
if (name == "user") user = field.value;
else if (name == "usr") user = field.value;
else if (name == "username") user = field.value;
else if (name == "login") user = field.value;
all_logins.push(field.value);
}
}
}
type_filters.push("text");
type_filters.push("email");
logins = try_get_name(fields, type_filters, true);
if (user != null)
logins = new Array(user);
else
logins = all_logins;
// Get all other fields except text, email and password
if (!logins.length)
{
type_filters.push("password");
logins = try_get_name(fields, type_filters, false);
}
// Look for <input type="password" value="@@...">
for (var i=0; i<fields.length; i++)

View File

@ -17,7 +17,7 @@
along with gPass. If not, see <http://www.gnu.org/licenses/>.
*/
var hmac = require("hmac").hmac;
var hmac = require("lib/hmac").hmac;
exports.pkdbf2 = {

View File

@ -1,13 +1,14 @@
{
"name": "gpass",
"fullName": "gPass",
"id": "jid1-eNs887pPJU8aNg",
"id": "jid1-eNs887pPJU8aNg@jetpack",
"main": "lib/main.js",
"description": "gPass : global password manager",
"author": "Grégory Soutadé",
"license": "GNU GPL v3",
"homepage" : "http://indefero.soutade.fr/p/gpass",
"icon" : "data/gpass_icon_64.png",
"version": "0.6",
"version": "0.7.0",
"preferences": [
{
"name": "account_url",