Skip to content

Commit

Permalink
Trick chrome into autofilling dummy username/password inputs
Browse files Browse the repository at this point in the history
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
  • Loading branch information
knolleary committed Feb 6, 2020
1 parent 0f1ca1c commit bbd471a
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -582,11 +582,12 @@ RED.editor = (function() {

// Add dummy fields to prevent 'Enter' submitting the form in some
// cases, and also prevent browser auto-fill of password
// Add in reverse order as they are prepended...
$('<input type="password" style="display: none;" />').prependTo(dialogForm);
$('<input type="text" style="display: none;" />').prependTo(dialogForm);
// - the elements cannot be hidden otherwise Chrome will ignore them.
// - the elements need to have id's that imply password/username
$('<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.find('input').attr("autocomplete","disable");
dialogForm.find('input').attr("autocomplete","off");
return dialogForm;
}

Expand Down

0 comments on commit bbd471a

Please sign in to comment.