From 475823821b5c475d5b352cdf5dabe4a835dca589 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 20 Oct 2021 11:58:35 +0200 Subject: [PATCH] Hide all passwords upon form submission in Core/Ui/Password.ts Resolves #4554 --- ts/WoltLabSuite/Core/Ui/Password.ts | 9 +++++++++ .../install/files/js/WoltLabSuite/Core/Ui/Password.js | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/ts/WoltLabSuite/Core/Ui/Password.ts b/ts/WoltLabSuite/Core/Ui/Password.ts index 7576117fe5..84b8760207 100644 --- a/ts/WoltLabSuite/Core/Ui/Password.ts +++ b/ts/WoltLabSuite/Core/Ui/Password.ts @@ -57,6 +57,15 @@ function initElement(input: HTMLInputElement): void { } }); + // Hide the password when the form is being submitted to prevent + // it from being stored within the web browser's autocomplete list. + // see https://github.com/WoltLab/WCF/issues/4554 + input.form?.addEventListener("submit", () => { + if (input.type !== "password") { + toggle(input, button, icon); + } + }); + if (activeElement === input) { input.focus(); } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Password.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Password.js index 1279d79b30..27caa04661 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Password.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Password.js @@ -26,6 +26,7 @@ define(["require", "exports", "tslib", "../Dom/Change/Listener", "../Language"], }); } function initElement(input) { + var _a; _knownElements.add(input); const activeElement = document.activeElement; const inputAddon = document.createElement("div"); @@ -51,6 +52,14 @@ define(["require", "exports", "tslib", "../Dom/Change/Listener", "../Language"], toggle(input, button, icon); } }); + // Hide the password when the form is being submitted to prevent + // it from being stored within the web browser's autocomplete list. + // see https://github.com/WoltLab/WCF/issues/4554 + (_a = input.form) === null || _a === void 0 ? void 0 : _a.addEventListener("submit", () => { + if (input.type !== "password") { + toggle(input, button, icon); + } + }); if (activeElement === input) { input.focus(); } -- 2.20.1