Merge pull request #534 from keepassxreboot/fix/auto_submit

Fix auto-submit
This commit is contained in:
Sami Vänttinen 2019-05-08 15:22:38 +03:00 committed by GitHub
commit d7a49c675e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1339,12 +1339,26 @@ kpxc.fillIn = function(combination, onlyPassword, suppressWarnings) {
}
}
// Get the form submit button instead if action URL is same as the page itself
function getSubmitButton(form) {
if (kpxc.submitUrl === document.location.origin + document.location.pathname) {
for (const i of form.elements) {
if (i.type === 'submit') {
return i;
}
}
}
return undefined;
}
// Auto-submit
if (kpxc.settings.autoSubmit) {
if (kpxc.u.form) {
kpxc.u.form.submit();
} else if (kpxc.p.form) {
kpxc.u.form.submit();
const form = kpxc.u.form || kpxc.p.form;
const submitButton = getSubmitButton(form);
if (submitButton !== undefined) {
submitButton.click();
} else {
form.submit();
}
}
};