mirror of
https://github.com/bitwarden/web
synced 2025-12-19 01:33:35 +00:00
catch bad data on all importers
This commit is contained in:
@@ -190,8 +190,7 @@
|
|||||||
function parseData(data) {
|
function parseData(data) {
|
||||||
var folders = [],
|
var folders = [],
|
||||||
sites = [],
|
sites = [],
|
||||||
siteRelationships = [],
|
siteRelationships = [];
|
||||||
badDataSites = 0;
|
|
||||||
|
|
||||||
angular.forEach(data, function (value, key) {
|
angular.forEach(data, function (value, key) {
|
||||||
var folderIndex = folders.length,
|
var folderIndex = folders.length,
|
||||||
@@ -209,10 +208,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!value.name || value.name === '') && (!value.password || value.password === '')) {
|
|
||||||
badDataSites++;
|
|
||||||
}
|
|
||||||
|
|
||||||
sites.push({
|
sites.push({
|
||||||
favorite: value.fav === '1',
|
favorite: value.fav === '1',
|
||||||
uri: value.url && value.url !== '' ? trimUri(value.url) : null,
|
uri: value.url && value.url !== '' ? trimUri(value.url) : null,
|
||||||
@@ -237,14 +232,9 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (badDataSites && badDataSites > (data.length / 2)) {
|
|
||||||
error('CSV data is not formatted correctly from LastPass. Please check your import file and try again.');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
success(folders, sites, siteRelationships);
|
success(folders, sites, siteRelationships);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function importSafeInCloudCsv(file, success, error) {
|
function importSafeInCloudCsv(file, success, error) {
|
||||||
Papa.parse(file, {
|
Papa.parse(file, {
|
||||||
|
|||||||
@@ -13,10 +13,17 @@
|
|||||||
|
|
||||||
function importSuccess(folders, sites, folderRelationships) {
|
function importSuccess(folders, sites, folderRelationships) {
|
||||||
if (!folders.length && !sites.length) {
|
if (!folders.length && !sites.length) {
|
||||||
$uibModalInstance.dismiss('cancel');
|
importError('Nothing was imported.');
|
||||||
toastr.error('Nothing was imported.');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else if (sites.length) {
|
||||||
|
var halfway = Math.floor(sites.length / 2);
|
||||||
|
var last = sites.length - 1;
|
||||||
|
if (siteIsBadData(sites[0]) && siteIsBadData(sites[halfway]) && siteIsBadData(sites[last])) {
|
||||||
|
importError('CSV data is not formatted correctly. Please check your import file and try again.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
apiService.ciphers.import({
|
apiService.ciphers.import({
|
||||||
folders: cipherService.encryptFolders(folders, cryptoService.getKey()),
|
folders: cipherService.encryptFolders(folders, cryptoService.getKey()),
|
||||||
@@ -31,6 +38,10 @@
|
|||||||
}, importError);
|
}, importError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function siteIsBadData(site) {
|
||||||
|
return (site.name === null || site.name === '--') && (site.password === null || site.password === '');
|
||||||
|
}
|
||||||
|
|
||||||
function importError(error) {
|
function importError(error) {
|
||||||
$analytics.eventTrack('Import Data Failed', { label: $scope.model.source });
|
$analytics.eventTrack('Import Data Failed', { label: $scope.model.source });
|
||||||
$uibModalInstance.dismiss('cancel');
|
$uibModalInstance.dismiss('cancel');
|
||||||
|
|||||||
Reference in New Issue
Block a user