Because the regular PHP inequality check is used on passwords, passwords which are numerically equivalent are accepted as the same.
On the edit user page, enter 99999.0 and 99999
The javascript will say they do not match, but submitting the form results in the message "The changes have been saved", and indeed they have.
Discovered on 6.10, confirmed that it exists in 7.x dev and probably all other versions of Drupal.
Presumably the solution is to replace the comparator in form.inc.
Change this:
function password_confirm_validate($form, &$form_state) {
...
if ($pass1 != $pass2) {
form_error($form, t('The specified passwords do not match.'));
}
with this:
function password_confirm_validate($form, &$form_state) {
...
if (!($pass1 === $pass2)) {
form_error($form, t('The specified passwords do not match.'));
}
Comments
Comment #1
alexanderpas commentedafaics that is indeed the issue there.
Comment #2
alexanderpas commentedcode for 6.x and also for 7.x but missing textcase ;)
Pondering on where to place the testcase for 7.x
any insights?
Comment #3
kscheirergood catch!
rerolled patch against HEAD, and added a test case in user.test that attempts to save the type-mismatched passwords.
Comment #4
kscheirerbetter title
Comment #5
lilou commentedPatch look good.
Comment #6
deekayen commentedI think more accurately what you're looking for is that the string values are the same, not necessarily that the variables are of the same type. How about strcmp()?
Comment #7
kscheirerPersonally I find !== a little clearer to read, but overall there's no big difference, since this block of code gets so rarely executed. Here ya go with strcmp()...
Comment #8
alexanderpas commentedI also think
strcmp()is more accurate, i'm in favor of it!Comment #9
webchickWow, what a silly bug! And a test case! Hooray! :D
I agree strcmp() seems safer here just in case your password is something truly crazy.
Committed to HEAD. We should probably port this to 6.x too, methinks.
Comment #10
alexanderpas commentedport for D6 ;)
Comment #11
andypostApplies clean so as straight forward
Comment #12
gábor hojtsyCommitted to Drupal 6, thanks.