Merge pull request #2324 from keepassxreboot/fix/nodename_check

Fix nodeName check
This commit is contained in:
Sami Vänttinen 2024-08-24 14:16:30 +03:00 committed by GitHub
commit 17a5fa5f45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 17 additions and 17 deletions

View file

@ -102,7 +102,7 @@ kpxcSites.exceptionFound = function(identifier, field) {
* @returns {boolean} True if an Element has a match with the needed indentfifiers and document location
*/
kpxcSites.totpExceptionFound = function(field) {
if (!field || !matchesWithNodeName(field.nodeName, 'INPUT')) {
if (!field || !matchesWithNodeName(field, 'INPUT')) {
return false;
}
@ -121,7 +121,7 @@ kpxcSites.totpExceptionFound = function(field) {
* @returns {boolean} True if an Element has a match with the needed indentfifiers and document location
*/
kpxcSites.segmentedTotpExceptionFound = function(form) {
if (!form || !matchesWithNodeName(form.nodeName, 'FORM')) {
if (!form || !matchesWithNodeName(form, 'FORM')) {
return false;
}

View file

@ -115,7 +115,7 @@ kpxcFields.getSegmentedTOTPFields = function(inputs, combinations) {
const addTotpFieldsToCombination = function(inputFields, ignoreFieldCount = false) {
const totpInputs = Array.from(inputFields).filter(
(e) =>
matchesWithNodeName(e.nodeName, 'INPUT') &&
matchesWithNodeName(e, 'INPUT') &&
e.type !== 'password' &&
e.type !== 'hidden' &&
e.type !== 'submit'
@ -155,8 +155,8 @@ kpxcFields.getSegmentedTOTPFields = function(inputs, combinations) {
// 7 inputs with a button as the last one (e.g. PayPal uses this)
if (
currentForm.length === 7 &&
(matchesWithNodeName(currentForm.lastChild.nodeName, 'BUTTON') ||
(matchesWithNodeName(currentForm.lastChild.nodeName, 'INPUT') &&
(matchesWithNodeName(currentForm.lastChild, 'BUTTON') ||
(matchesWithNodeName(currentForm.lastChild, 'INPUT') &&
currentForm.lastChild.type === 'button'))
) {
return true;

View file

@ -246,7 +246,7 @@ kpxcFill.fillInCredentials = async function(combination, predefinedUsername, uui
}
// Fill password
if (combination.password && matchesWithNodeName(combination.password.nodeName, 'INPUT')) {
if (combination.password && matchesWithNodeName(combination.password, 'INPUT')) {
// Show a notification if password length exceeds the length defined in input
if (combination.password.maxLength
&& combination.password.maxLength > 0

View file

@ -58,8 +58,8 @@ kpxcForm.getFormSubmitButton = function(form) {
// Try to find similar buttons outside the form which are added via 'form' property
for (const e of form.elements) {
if ((matchesWithNodeName(e.nodeName, 'BUTTON') && (e.type === 'button' || e.type === 'submit' || e.type === ''))
|| (matchesWithNodeName(e.nodeName, 'INPUT') && (e.type === 'button' || e.type === 'submit'))) {
if ((matchesWithNodeName(e, 'BUTTON') && (e.type === 'button' || e.type === 'submit' || e.type === ''))
|| (matchesWithNodeName(e, 'INPUT') && (e.type === 'button' || e.type === 'submit'))) {
return e;
}
}
@ -127,13 +127,13 @@ kpxcForm.onSubmit = async function(e) {
kpxcForm.submitTriggered = true;
const searchForm = f => {
if (matchesWithNodeName(f.nodeName, 'FORM')) {
if (matchesWithNodeName(f, 'FORM')) {
return f;
}
};
// Traverse parents if the form is not found.
let form = matchesWithNodeName(this.nodeName, 'FORM')
let form = matchesWithNodeName(this, 'FORM')
? this
: kpxcFields.traverseParents(this, searchForm, searchForm, () => null);
@ -207,10 +207,10 @@ kpxcForm.saveForm = function(form, combination) {
password: combination.password,
totp: combination.totp,
totpInputs: Array.from(form.elements).filter(
e => matchesWithNodeName(e.nodeName, 'INPUT') && kpxcTOTPIcons.isValid(e),
e => matchesWithNodeName(e, 'INPUT') && kpxcTOTPIcons.isValid(e),
),
passwordInputs: Array.from(form.elements).filter(
e => matchesWithNodeName(e.nodeName, 'INPUT') && e.type === 'password',
e => matchesWithNodeName(e, 'INPUT') && e.type === 'password',
)
});
};

View file

@ -600,7 +600,7 @@ kpxc.rememberCredentialsFromContextMenu = async function() {
}
const el = document.activeElement;
if (!matchesWithNodeName(el.nodeName, 'INPUT')) {
if (!matchesWithNodeName(el, 'INPUT')) {
return;
}

View file

@ -73,7 +73,7 @@ kpxcObserverHelper.initObserver = async function() {
}
} else if (mut.type === 'attributes' && (mut.attributeName === 'class' || mut.attributeName === 'style')) {
// Only accept targets with forms
const forms = matchesWithNodeName(mut.target.nodeName, 'FORM') ? mut.target : mut.target.getElementsByTagName('form');
const forms = matchesWithNodeName(mut.target, 'FORM') ? mut.target : mut.target.getElementsByTagName('form');
if (forms.length === 0 && !kpxcSites.exceptionFound(mut.target.classList, mut.target)) {
continue;
}
@ -146,7 +146,7 @@ kpxcObserverHelper.getInputs = function(target, ignoreVisibility = false) {
}
});
if (matchesWithNodeName(target.nodeName, 'INPUT')) {
if (matchesWithNodeName(target, 'INPUT')) {
inputFields.push(target);
}
@ -304,7 +304,7 @@ const traverseChildren = function(target, inputFields, depth = 1) {
continue;
}
if (matchesWithNodeName(child.nodeName, 'INPUT')) {
if (matchesWithNodeName(child, 'INPUT')) {
inputFields.push(child);
}

View file

@ -133,7 +133,7 @@ kpxcUI.monitorIconPosition = function(iconClass) {
});
window.addEventListener('transitionend', function(e) {
if (matchesWithNodeName(e.target?.nodeName, 'INPUT') || matchesWithNodeName(e.target?.nodeName, 'TEXTAREA')) {
if (matchesWithNodeName(e.target, 'INPUT') || matchesWithNodeName(e.target, 'TEXTAREA')) {
kpxcUI.updateIconPosition(iconClass);
}
});