mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-02 18:17:46 +01:00
update importer for firefox
This commit is contained in:
parent
c326e03eb2
commit
cd9a43f359
@ -40,8 +40,8 @@
|
||||
case 'operacsv':
|
||||
importChromeCsv(file, success, error);
|
||||
break;
|
||||
case 'firefoxpasswordexportercsvxml':
|
||||
importFirefoxPasswordExporterCsvXml(file, success, error);
|
||||
case 'firefoxpasswordexportercsv':
|
||||
importFirefoxPasswordExporterCsv(file, success, error);
|
||||
break;
|
||||
case 'upmcsv':
|
||||
importUpmCsv(file, success, error);
|
||||
@ -173,6 +173,12 @@
|
||||
'ort', 'adresse'
|
||||
];
|
||||
|
||||
function loginNameFromUrl(url) {
|
||||
var a = document.createElement('a');
|
||||
a.href = url;
|
||||
return a.hostname.startsWith('www.') ? a.hostname.replace('www.', '') : a.hostname;
|
||||
}
|
||||
|
||||
function isField(fieldText, refFieldValues) {
|
||||
if (!fieldText || fieldText === '') {
|
||||
return false;
|
||||
@ -1484,65 +1490,34 @@
|
||||
});
|
||||
}
|
||||
|
||||
function importFirefoxPasswordExporterCsvXml(file, success, error) {
|
||||
var folders = [],
|
||||
ciphers = [];
|
||||
function importFirefoxPasswordExporterCsv(file, success, error) {
|
||||
Papa.parse(file, {
|
||||
header: true,
|
||||
encoding: 'UTF-8',
|
||||
complete: function (results) {
|
||||
parseCsvErrors(results);
|
||||
|
||||
function getNameFromHost(host) {
|
||||
var name = '--';
|
||||
try {
|
||||
if (host && host !== '') {
|
||||
var parser = document.createElement('a');
|
||||
parser.href = host;
|
||||
if (parser.hostname) {
|
||||
name = parser.hostname;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
// do nothing
|
||||
}
|
||||
var folders = [],
|
||||
ciphers = [];
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
function parseXml(xmlDoc) {
|
||||
var xml = $(xmlDoc);
|
||||
|
||||
var entries = xml.find('entry');
|
||||
for (var i = 0; i < entries.length; i++) {
|
||||
var entry = $(entries[i]);
|
||||
if (!entry) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var host = entry.attr('host'),
|
||||
user = entry.attr('user'),
|
||||
password = entry.attr('password');
|
||||
|
||||
ciphers.push({
|
||||
type: constants.cipherType.login,
|
||||
favorite: false,
|
||||
notes: null,
|
||||
name: getNameFromHost(host),
|
||||
login: {
|
||||
uris: makeUriArray(host),
|
||||
username: user && user !== '' ? user : null,
|
||||
password: password && password !== '' ? password : null,
|
||||
}
|
||||
angular.forEach(results.data, function (value, key) {
|
||||
|
||||
ciphers.push({
|
||||
type: constants.cipherType.login,
|
||||
favorite: false,
|
||||
notes: null,
|
||||
name: value.hostname && value.hostname !== '' ? loginNameFromUrl(value.hostname) : '--',
|
||||
login: {
|
||||
uris: makeUriArray(value.hostname),
|
||||
username: value.username && value.username !== '' ? value.username : null,
|
||||
password: value.password && value.password !== '' ? value.password : null
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
success(folders, ciphers, []);
|
||||
}
|
||||
|
||||
success(folders, ciphers, []);
|
||||
}
|
||||
|
||||
if (file.type && file.type === 'text/xml') {
|
||||
getXmlFileContents(file, parseXml, error);
|
||||
}
|
||||
else {
|
||||
error('Only .xml exports are supported.');
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function importUpmCsv(file, success, error) {
|
||||
@ -2601,12 +2576,6 @@
|
||||
}
|
||||
|
||||
function importSaferPassCsv(file, success, error) {
|
||||
function urlDomain(data) {
|
||||
var a = document.createElement('a');
|
||||
a.href = data;
|
||||
return a.hostname.startsWith('www.') ? a.hostname.replace('www.', '') : a.hostname;
|
||||
}
|
||||
|
||||
var folders = [],
|
||||
ciphers = [];
|
||||
|
||||
@ -2621,7 +2590,7 @@
|
||||
type: constants.cipherType.login,
|
||||
favorite: false,
|
||||
notes: value.notes && value.notes !== '' ? value.notes : null,
|
||||
name: value.url && value.url !== '' ? urlDomain(value.url) : '--',
|
||||
name: value.url && value.url !== '' ? loginNameFromUrl(value.url) : '--',
|
||||
login: {
|
||||
uris: makeUriArray(value.url),
|
||||
username: value.username && value.username !== '' ? value.username : null,
|
||||
|
@ -36,16 +36,13 @@
|
||||
'https://help.bitwarden.com/article/import-from-chrome/</a>')
|
||||
},
|
||||
{
|
||||
id: 'firefoxpasswordexportercsvxml',
|
||||
name: 'Firefox Password Exporter (xml)',
|
||||
id: 'firefoxpasswordexportercsv',
|
||||
name: 'Firefox Password Exporter (csv)',
|
||||
featured: true,
|
||||
sort: 4,
|
||||
instructions: $sce.trustAsHtml('Use the ' +
|
||||
'<a target="_blank" href="https://addons.mozilla.org/en-US/firefox/addon/password-exporter/">' +
|
||||
'Password Exporter</a> addon for FireFox to export your passwords to a XML file. After installing ' +
|
||||
'the addon, type <code>about:addons</code> in your FireFox navigation bar. Locate the Password Exporter ' +
|
||||
'addon and click the "Options" button. In the dialog that pops up, click the "Export Passwords" button ' +
|
||||
'to save the XML file.')
|
||||
'<a target="_blank" href="https://github.com/kspearrin/ff-password-exporter#ff-password-exporter">' +
|
||||
'FF Password Exporter</a> application to export your passwords to a CSV file.')
|
||||
},
|
||||
{
|
||||
id: 'keepass2xml',
|
||||
|
Loading…
Reference in New Issue
Block a user