diff options
author | varjolintu <sami.vanttinen@protonmail.com> | 2019-03-16 10:14:59 +0300 |
---|---|---|
committer | varjolintu <sami.vanttinen@protonmail.com> | 2019-03-16 10:17:56 +0300 |
commit | 570ca76ccac9f2a40fc9ca36fcc6736fe3c6bd11 (patch) | |
tree | c56f2e464ca86dc9ea7fa968cdb2216c5e574233 /keepassxc-browser/keepassxc-browser.js | |
parent | c3a36027b53b908c36e8ccc6d9e1ebf62ae979db (diff) |
Prevent scripts to use autocomplete
Diffstat (limited to 'keepassxc-browser/keepassxc-browser.js')
-rwxr-xr-x | keepassxc-browser/keepassxc-browser.js | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/keepassxc-browser/keepassxc-browser.js b/keepassxc-browser/keepassxc-browser.js index 26f41e3..5064845 100755 --- a/keepassxc-browser/keepassxc-browser.js +++ b/keepassxc-browser/keepassxc-browser.js @@ -127,11 +127,17 @@ cipAutocomplete.init = function(field) { .focus(cipAutocomplete.onFocus); }; -cipAutocomplete.onClick = function() { +cipAutocomplete.onClick = function(e) { + if (!cipAutocomplete.isTrusted(e)) { + return; + } jQuery(this).autocomplete('search', jQuery(this).val()); }; -cipAutocomplete.onOpen = function(event, ui) { +cipAutocomplete.onOpen = function(e, ui) { + if (!cipAutocomplete.isTrusted(e)) { + return; + } jQuery('ul.ui-autocomplete.ui-menu').css('z-index', 2147483636); }; @@ -145,6 +151,9 @@ cipAutocomplete.onSource = function(request, callback) { }; cipAutocomplete.onSelect = function(e, ui) { + if (!cipAutocomplete.isTrusted(e)) { + return; + } e.preventDefault(); cip.setValueWithChange(jQuery(this), ui.item.value); const fieldId = cipFields.prepareId(jQuery(this).attr('data-cip-id')); @@ -171,7 +180,10 @@ cipAutocomplete.onBlur = function() { } }; -cipAutocomplete.onFocus = function() { +cipAutocomplete.onFocus = function(e) { + if (!cipAutocomplete.isTrusted(e)) { + return; + } cip.u = jQuery(this); if (jQuery(this).val() === '') { @@ -179,6 +191,17 @@ cipAutocomplete.onFocus = function() { } }; +// Search for isTrusted from jQuery's originalEvent +cipAutocomplete.isTrusted = function(e) { + for (let f = e.originalEvent; f !== null; f = f.originalEvent) { + if (f.isTrusted !== undefined) { + return f.isTrusted; + } + } + return false; +}; + + var cipPassword = {}; cipPassword.observedIcons = []; cipPassword.observingLock = false; |