From 9405be03b059d819622259d542503c66f2c9a6b3 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 9 Nov 2016 18:18:46 -0500 Subject: [PATCH] Added importer for universal password manager csv format --- src/Web/wwwroot/app/services/importService.js | 31 +++++++++++++++++++ .../wwwroot/app/tools/views/toolsImport.html | 1 + 2 files changed, 32 insertions(+) diff --git a/src/Web/wwwroot/app/services/importService.js b/src/Web/wwwroot/app/services/importService.js index 8bfd51c0fc..98b4758a99 100644 --- a/src/Web/wwwroot/app/services/importService.js +++ b/src/Web/wwwroot/app/services/importService.js @@ -38,6 +38,9 @@ case 'firefoxpasswordexportercsvxml': importFirefoxPasswordExporterCsvXml(file, success, error); break; + case 'upmcsv': + importUpmCsv(file, success, error); + break; default: error(); break; @@ -749,5 +752,33 @@ } } + function importUpmCsv(file, success, error) { + Papa.parse(file, { + encoding: 'UTF-8', + complete: function (results) { + parseCsvErrors(results); + + var folders = [], + sites = [], + siteRelationships = []; + + angular.forEach(results.data, function (value, key) { + if (value.length === 5) { + sites.push({ + favorite: false, + uri: value[3] && value[3] !== '' ? trimUri(value[3]) : null, + username: value[1] && value[1] !== '' ? value[1] : null, + password: value[2] && value[2] !== '' ? value[2] : null, + notes: value[4] && value[4] !== '' ? value[4] : null, + name: value[0] && value[0] !== '' ? value[0] : '--', + }); + } + }); + + success(folders, sites, siteRelationships); + } + }); + } + return _service; }); diff --git a/src/Web/wwwroot/app/tools/views/toolsImport.html b/src/Web/wwwroot/app/tools/views/toolsImport.html index 2e54e54158..408174abfa 100644 --- a/src/Web/wwwroot/app/tools/views/toolsImport.html +++ b/src/Web/wwwroot/app/tools/views/toolsImport.html @@ -16,6 +16,7 @@ +