From 6d82fb5bbc5ab69968154047d3add4344ec9f624 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 21 Jun 2019 08:19:38 -0400 Subject: [PATCH] support old CSV format for password agent --- src/importers/passwordAgentCsvImporter.ts | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/importers/passwordAgentCsvImporter.ts b/src/importers/passwordAgentCsvImporter.ts index 444585661c..6095fcbb52 100644 --- a/src/importers/passwordAgentCsvImporter.ts +++ b/src/importers/passwordAgentCsvImporter.ts @@ -12,25 +12,32 @@ export class PasswordAgentCsvImporter extends BaseImporter implements Importer { return result; } + let newVersion = true; results.forEach((value) => { - if (value.length < 9) { + if (value.length !== 5 && value.length < 9) { return; } - const folder = this.getValueOrDefault(value[8], '(None)'); - const folderName = folder !== '(None)' ? folder.split('\\').join('/') : null; - this.processFolder(result, folderName); const cipher = this.initLoginCipher(); - cipher.notes = this.getValueOrDefault(value[3]); cipher.name = this.getValueOrDefault(value[0], '--'); cipher.login.username = this.getValueOrDefault(value[1]); cipher.login.password = this.getValueOrDefault(value[2]); - cipher.login.uris = this.makeUriArray(value[4]); + if (value.length === 5) { + newVersion = false; + cipher.notes = this.getValueOrDefault(value[4]); + cipher.login.uris = this.makeUriArray(value[3]); + } else { + const folder = this.getValueOrDefault(value[8], '(None)'); + const folderName = folder !== '(None)' ? folder.split('\\').join('/') : null; + this.processFolder(result, folderName); + cipher.notes = this.getValueOrDefault(value[3]); + cipher.login.uris = this.makeUriArray(value[4]); + } this.convertToNoteIfNeeded(cipher); this.cleanupCipher(cipher); result.ciphers.push(cipher); }); - if (this.organization) { + if (newVersion && this.organization) { this.moveFoldersToCollections(result); }