From 0f8332b07a6b8fb42825d07527e093c6a9e4e640 Mon Sep 17 00:00:00 2001 From: Aetherinox Date: Sun, 7 Apr 2024 12:06:11 -0700 Subject: [PATCH 1/3] fix: convert space character to non-breaking space on password reveal addresses issue with having space characters in passwords and pressing the 'reveal password' button. --- app/scripts/util/formatting/password-presenter.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/scripts/util/formatting/password-presenter.js b/app/scripts/util/formatting/password-presenter.js index a7271077..38de5f40 100644 --- a/app/scripts/util/formatting/password-presenter.js +++ b/app/scripts/util/formatting/password-presenter.js @@ -7,8 +7,14 @@ class RandomNameGenerator { } } +// activated when user presses 'reveal' on password function charCodeToHtml(char) { - return Math.random() < 0.2 ? String.fromCharCode(char) : `&#x${char.toString(16)};`; + // convert certain special chars like space into to non-breaking space + // ' ' to &#nbsp; + if ( char === 32 || char === 8193 || char === 8239 ) + char = 160; + + return Math.random( ) < 0.2 ? String.fromCharCode( char ) : `&#x${ char.toString( 16 ) };`; } const PasswordPresenter = { From fe23aa9097e4c96199e2924cacb7ac629fb42ef0 Mon Sep 17 00:00:00 2001 From: Aetherinox Date: Sun, 7 Apr 2024 12:11:43 -0700 Subject: [PATCH 2/3] chore: conform to prettify --- app/scripts/util/formatting/password-presenter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/scripts/util/formatting/password-presenter.js b/app/scripts/util/formatting/password-presenter.js index 38de5f40..42503a6c 100644 --- a/app/scripts/util/formatting/password-presenter.js +++ b/app/scripts/util/formatting/password-presenter.js @@ -11,9 +11,9 @@ class RandomNameGenerator { function charCodeToHtml(char) { // convert certain special chars like space into to non-breaking space // ' ' to &#nbsp; - if ( char === 32 || char === 8193 || char === 8239 ) + if ( char === 32 || char === 8193 || char === 8239 ) { char = 160; - + } return Math.random( ) < 0.2 ? String.fromCharCode( char ) : `&#x${ char.toString( 16 ) };`; } From ab9b5a9d683c4f6360d119bc3155e349fcebd30a Mon Sep 17 00:00:00 2001 From: Aetherinox Date: Sun, 7 Apr 2024 12:44:46 -0700 Subject: [PATCH 3/3] fix: prettify linting rage inducing --- app/scripts/util/formatting/password-presenter.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/scripts/util/formatting/password-presenter.js b/app/scripts/util/formatting/password-presenter.js index 42503a6c..584a0865 100644 --- a/app/scripts/util/formatting/password-presenter.js +++ b/app/scripts/util/formatting/password-presenter.js @@ -7,14 +7,13 @@ class RandomNameGenerator { } } -// activated when user presses 'reveal' on password function charCodeToHtml(char) { // convert certain special chars like space into to non-breaking space // ' ' to &#nbsp; - if ( char === 32 || char === 8193 || char === 8239 ) { + if (char === 32 || char === 8193 || char === 8239) { char = 160; } - return Math.random( ) < 0.2 ? String.fromCharCode( char ) : `&#x${ char.toString( 16 ) };`; + return Math.random() < 0.2 ? String.fromCharCode(char) : `&#x${char.toString(16)};`; } const PasswordPresenter = {