1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Trick chrome into autofilling dummy username/password inputs

Fixes #2445

Continuing the arms race against Chrome's war on developers getting
to choose if a form should be autocompleted or not.

The honey-pot username/password fields we already had were being
ignored. This is because they were hidden.

This fix does three things:

 - unhides the honey-pot inputs, but moves them offscreen so they won't be seen
 - gives them dummy id's so Chrome thinks they are username/password fields
 - updates our autocomplete setting to be the standards-compliant 'off' for all
  the other browsers who adhere to the standard
This commit is contained in:
Nick O'Leary 2020-02-06 15:36:23 +00:00
parent 0f1ca1c7cf
commit bbd471ad93
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -582,11 +582,12 @@ RED.editor = (function() {
// Add dummy fields to prevent 'Enter' submitting the form in some // Add dummy fields to prevent 'Enter' submitting the form in some
// cases, and also prevent browser auto-fill of password // cases, and also prevent browser auto-fill of password
// Add in reverse order as they are prepended... // - the elements cannot be hidden otherwise Chrome will ignore them.
$('<input type="password" style="display: none;" />').prependTo(dialogForm); // - the elements need to have id's that imply password/username
$('<input type="text" style="display: none;" />').prependTo(dialogForm); $('<div style="position: absolute; top: -2000px;"><input id="red-ui-trap-password" type="password"/></div>').prependTo(dialogForm);
$('<div style="position: absolute; top: -2000px;"><input id="red-ui-trap-username" type="text"/></div>').prependTo(dialogForm);
dialogForm.on("submit", function(e) { e.preventDefault();}); dialogForm.on("submit", function(e) { e.preventDefault();});
dialogForm.find('input').attr("autocomplete","disable"); dialogForm.find('input').attr("autocomplete","off");
return dialogForm; return dialogForm;
} }