Merge pull request #1487 from keepassxreboot/fix/aws_auto-submit

Fix Auto-Submit with Amazon AWS
This commit is contained in:
Sami Vänttinen 2021-12-04 20:28:41 +02:00 committed by GitHub
commit e27115a894
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 19 deletions

View file

@ -61,10 +61,12 @@ const PREDEFINED_SITELIST = [
'https://secure.fnac.com/identity/server/gateway/*'
];
const awsUrl = 'signin.aws.amazon.com';
const ebayUrl = 'https://www.ebay.';
const googleUrl = 'https://accounts.google.com';
const kpxcSites = {};
kpxcSites.ebayUrl = 'https://www.ebay.';
kpxcSites.googlePasswordFormUrl = 'https://accounts.google.com/signin/v2/challenge/password';
kpxcSites.googleUrl = 'https://accounts.google.com';
kpxcSites.savedForm = undefined;
/**
@ -127,3 +129,36 @@ kpxcSites.expectedTOTPMaxLength = function() {
return MAX_TOTP_INPUT_LENGTH;
};
/**
* Handles a few exceptions for certain sites where form submit button is not regognized properly.
* @param {object} form Form element
* @returns {object} Button element
*/
kpxcSites.formSubmitButtonExceptionFound = function(form) {
if (form.action.startsWith(googleUrl)) {
const findDiv = $('#identifierNext, #passwordNext');
if (!findDiv) {
return undefined;
}
const buttons = findDiv.getElementsByTagName('button');
kpxcSites.savedForm = form;
return buttons.length > 0 ? buttons[0] : undefined;
} else if (form.action.startsWith(ebayUrl)) {
// For eBay we must return the first button.
for (const i of form.elements) {
if (i.type === 'button') {
return i;
}
}
} else if (form.action.includes(awsUrl)) {
// For Amazon AWS the button is outside the form.
const button = $('#signin_button');
if (button) {
return button;
}
}
return undefined;
};

View file

@ -160,23 +160,10 @@ kpxcForm.getFormSubmitButton = function(form) {
const action = kpxc.submitUrl || form.action;
// Special handling for accounts.google.com. The submit button is outside the form.
if (form.action.startsWith(kpxcSites.googleUrl)) {
const findDiv = $('#identifierNext, #passwordNext');
if (!findDiv) {
return undefined;
}
const buttons = findDiv.getElementsByTagName('button');
kpxcSites.savedForm = form;
return buttons.length > 0 ? buttons[0] : undefined;
} else if (form.action.startsWith(kpxcSites.ebayUrl)) {
// For eBay we must return the first button.
for (const i of form.elements) {
if (i.type === 'button') {
return i;
}
}
// Check if the site needs a special handling for retrieving the form submit button
const exceptionButton = kpxcSites.formSubmitButtonExceptionFound(form);
if (exceptionButton) {
return exceptionButton;
}
if (action.includes(document.location.origin + document.location.pathname)) {