From 896769b8bdedc1f6a97fc61ec3957d0f9e4666d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Harb=C3=B6ck?= Date: Mon, 24 Aug 2020 01:16:35 +0200 Subject: [PATCH] Hide password in detail view when using gopass v1.10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RELEASE_NOTES=Hide password in detail view when using gopass v1.10 Signed-off-by: Patrick Harböck --- tests/unit/details.test.js | 24 ++++++++++++++++++++++++ web-extension/details.js | 6 ++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/tests/unit/details.test.js b/tests/unit/details.test.js index d2138b5..c64d438 100644 --- a/tests/unit/details.test.js +++ b/tests/unit/details.test.js @@ -88,6 +88,30 @@ describe('onEntryData', () => { }); }); + test('filtered keys is case-insensitive', () => { + expect.assertions(2); + return details.onEntryData(loginElement, { MuH: 'value' }).then(() => { + expect(document.getElementsByClassName('detail-key').length).toBe(0); + expect(document.getElementsByClassName('detail-clickable-value').length).toBe(0); + }); + }); + + test('filtered keys always hides "password"', () => { + expect.assertions(2); + return details.onEntryData(loginElement, { password: 'value' }).then(() => { + expect(document.getElementsByClassName('detail-key').length).toBe(0); + expect(document.getElementsByClassName('detail-clickable-value').length).toBe(0); + }); + }); + + test('filtered keys always hides "Password"', () => { + expect.assertions(2); + return details.onEntryData(loginElement, { Password: 'value' }).then(() => { + expect(document.getElementsByClassName('detail-key').length).toBe(0); + expect(document.getElementsByClassName('detail-clickable-value').length).toBe(0); + }); + }); + test('url values', () => { expect.assertions(2); return details.onEntryData(loginElement, { hallo: 'https://hallo.welt' }).then(() => { diff --git a/web-extension/details.js b/web-extension/details.js index bb4a99d..32900a1 100644 --- a/web-extension/details.js +++ b/web-extension/details.js @@ -27,8 +27,10 @@ function _insertAfter(newNode, referenceNode) { } function _excludeKey(key, settings) { - const omit = settings.omitkeys.split(',').map(item => item.trim()); - return omit.some(value => value === key); + const _canonicalize = k => k.trim().toLowerCase(); + const omit = settings.omitkeys.split(','); + omit.push('password'); // Always exclude default "password/Password" key from detail view, user can use copy button + return omit.some(value => _canonicalize(value) === _canonicalize(key)); } function _detailViewFromMessage(message, settings) {