1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-03-12 13:39:14 +01:00

Report "importFormatError" when header translation did not work, instead of a generic undefined error (startsWith)

This commit is contained in:
Daniel James Smith 2024-12-03 13:44:00 +01:00
parent a957d7d564
commit 0b037303b1
No known key found for this signature in database
GPG Key ID: DA2E2EC600E1289B
2 changed files with 13 additions and 0 deletions

View File

@ -56,6 +56,12 @@ describe("PasswordXPCsvImporter", () => {
expect(result.success).toBe(false);
});
it("should return success false if CSV headers did not get translated", async () => {
const data = germanHeaders.replace("Titel;", "UnknownTitle;");
const result: ImportResult = await importer.parse(data);
expect(result.success).toBe(false);
});
it("should skip rows starting with >>>", async () => {
const result: ImportResult = await importer.parse(noFolder);
expect(result.success).toBe(true);

View File

@ -55,6 +55,13 @@ export class PasswordXPCsvImporter extends BaseImporter implements Importer {
result.success = false;
return Promise.resolve(result);
}
// If the first row (header check) does not contain the column "Title", then the data is invalid (no translation found)
if (!results[0].Title) {
result.success = false;
return Promise.resolve(result);
}
let currentFolderName = "";
results.forEach((row) => {
// Skip rows starting with '>>>' as they indicate items following have no folder assigned to them