Skip to content

Commit

Permalink
Merge pull request #169 from gopasspw/omit-password
Browse files Browse the repository at this point in the history
Hide password in detail view when using gopass v1.10
  • Loading branch information
Pharb authored Aug 23, 2020
2 parents ef028e5 + 896769b commit 100bfc2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
24 changes: 24 additions & 0 deletions tests/unit/details.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
6 changes: 4 additions & 2 deletions web-extension/details.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 100bfc2

Please sign in to comment.