1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-14 23:45:37 +00:00

[PM-25721] Retain leading spaces in imported fields. (#16411)

* Implement cleanupCipher method in BaseImporter with tests for notes and name handling

- Added cleanupCipher method to preserve leading/trailing spaces in notes and set them to null if they contain only whitespace or are empty.
- Updated the BaseImporter class to remove trimming of notes to maintain original formatting.
- Added unit tests for cleanupCipher to verify behavior for various note and name scenarios.

* Got rid of unneeded cipher spec test

* Got rid of unneeded comment

* Fix service and importers for tests to pass

* Fix sdk.service.ts

* Refactor URL normalization in ApiService to streamline request URL construction

* Fixed PR comments

* Add back comment

---------

Co-authored-by: Mike Amirault <mamirault@bitwarden.com>
This commit is contained in:
Jared
2026-01-05 11:48:10 -05:00
committed by GitHub
parent cf285abd3d
commit fe03052fe6
6 changed files with 9 additions and 8 deletions

View File

@@ -319,8 +319,6 @@ export abstract class BaseImporter {
}
if (this.isNullOrWhitespace(cipher.notes)) {
cipher.notes = null;
} else {
cipher.notes = cipher.notes.trim();
}
}

View File

@@ -64,7 +64,10 @@ export class EnpassJsonImporter extends BaseImporter implements Importer {
}
}
cipher.notes += "\n" + this.getValueOrDefault(item.note, "");
const note = this.getValueOrDefault(item.note, "");
if (note) {
cipher.notes = note.trimEnd();
}
this.convertToNoteIfNeeded(cipher);
this.cleanupCipher(cipher);
result.ciphers.push(cipher);

View File

@@ -21,7 +21,7 @@ export class KeeperCsvImporter extends BaseImporter implements Importer {
const notes = this.getValueOrDefault(value[5]);
if (notes) {
cipher.notes = `${notes}\n`;
cipher.notes = notes.trimEnd();
}
cipher.name = this.getValueOrDefault(value[1], "--");

View File

@@ -50,7 +50,7 @@ export class MykiCsvImporter extends BaseImporter implements Importer {
results.forEach((value) => {
const cipher = this.initLoginCipher();
cipher.name = this.getValueOrDefault(value.nickname, "--");
cipher.notes = this.getValueOrDefault(value.additionalInfo);
cipher.notes = this.getValueOrDefault(value.additionalInfo, "").trimEnd();
if (value.url !== undefined) {
// Accounts
@@ -132,7 +132,7 @@ export class MykiCsvImporter extends BaseImporter implements Importer {
cipher.secureNote = new SecureNoteView();
cipher.type = CipherType.SecureNote;
cipher.secureNote.type = SecureNoteType.Generic;
cipher.notes = this.getValueOrDefault(value.content);
cipher.notes = this.getValueOrDefault(value.content, "").trimEnd();
this.importUnmappedFields(cipher, value, _mappedUserNoteColumns);
} else {

View File

@@ -35,7 +35,7 @@ export class NetwrixPasswordSecureCsvImporter extends BaseImporter implements Im
const notes = this.getValueOrDefault(row.Informationen);
if (notes) {
cipher.notes = `${notes}\n`;
cipher.notes = notes.trimEnd();
}
cipher.name = this.getValueOrDefault(row.Beschreibung, "--");

View File

@@ -97,7 +97,7 @@ export class OnePassword1PuxImporter extends BaseImporter implements Importer {
this.processSections(category, item.details.sections, cipher);
if (!this.isNullOrWhitespace(item.details.notesPlain)) {
cipher.notes = item.details.notesPlain.split(this.newLineRegex).join("\n") + "\n";
cipher.notes = item.details.notesPlain.split(this.newLineRegex).join("\n").trimEnd();
}
this.convertToNoteIfNeeded(cipher);