From 0db179e97443db9996b8a65459516584ef7ba6c7 Mon Sep 17 00:00:00 2001 From: SmithThe4th Date: Mon, 23 Sep 2024 16:45:53 -0400 Subject: [PATCH] [PM-739] Using a space at the beginning of otpauth:// generate a wrong OTP (#11204) * Trimmed tariling whitespace from totp field * Trimmed tariling whitespace from totp field * Fix failing test --- libs/angular/src/vault/components/add-edit.component.ts | 5 +++++ .../login-details-section/login-details-section.component.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/angular/src/vault/components/add-edit.component.ts b/libs/angular/src/vault/components/add-edit.component.ts index 45475440d0..255d553a3e 100644 --- a/libs/angular/src/vault/components/add-edit.component.ts +++ b/libs/angular/src/vault/components/add-edit.component.ts @@ -329,6 +329,11 @@ export class AddEditComponent implements OnInit, OnDestroy { this.cipher.card.expYear = normalizeExpiryYearFormat(this.cipher.card.expYear); } + // trim whitespace from the TOTP field + if (this.cipher.type === this.cipherType.Login && this.cipher.login.totp) { + this.cipher.login.totp = this.cipher.login.totp.trim(); + } + if (this.cipher.name == null || this.cipher.name === "") { this.platformUtilsService.showToast( "error", diff --git a/libs/vault/src/cipher-form/components/login-details-section/login-details-section.component.ts b/libs/vault/src/cipher-form/components/login-details-section/login-details-section.component.ts index eb34f820df..691b05be2b 100644 --- a/libs/vault/src/cipher-form/components/login-details-section/login-details-section.component.ts +++ b/libs/vault/src/cipher-form/components/login-details-section/login-details-section.component.ts @@ -125,7 +125,7 @@ export class LoginDetailsSectionComponent implements OnInit { Object.assign(cipher.login, { username: value.username, password: value.password, - totp: value.totp, + totp: value.totp?.trim(), } as LoginView); return cipher;