[4.2] Validate passwords more safely

As requested.
Short array syntax
Merge pull request #5151 from KennedyTedesco/4.2-password-broker

[4.2] Validate passwords more safely
Fix conflicts.