Ticket #13655: stripslash-passwords-take-2.patch
File stripslash-passwords-take-2.patch, 2.5 KB (added by , 14 years ago) |
---|
-
wp-includes/registration.php
113 113 } else { 114 114 $update = false; 115 115 // Hash the password 116 $user_pass = wp_hash_password( $user_pass);116 $user_pass = wp_hash_password(stripslashes($user_pass)); 117 117 } 118 118 119 119 $user_login = sanitize_user($user_login, true); … … 267 267 // If password is changing, hash it now. 268 268 if ( ! empty($userdata['user_pass']) ) { 269 269 $plaintext_pass = $userdata['user_pass']; 270 $userdata['user_pass'] = wp_hash_password( $userdata['user_pass']);270 $userdata['user_pass'] = wp_hash_password(stripslashes($userdata['user_pass'])); 271 271 } 272 272 273 273 wp_cache_delete($user[ 'user_email' ], 'useremail'); -
wp-includes/pluggable.php
1459 1459 function wp_check_password($password, $hash, $user_id = '') { 1460 1460 global $wp_hasher; 1461 1461 1462 // If the hash is still md5... 1462 /* 1463 * For a long time WordPress did not stripslash() passwords correctly. 1464 * To handle these password hashes we must check against slashed 1465 * passwords and update on match. 1466 */ 1467 $slashed_password = $password; 1468 $password = stripslashes($password); 1469 1470 // If the hash is still md5 (as well as not stripslashed) 1463 1471 if ( strlen($hash) <= 32 ) { 1464 $check = ( $hash == md5($ password) );1472 $check = ( $hash == md5($slashed_password) ); 1465 1473 if ( $check && $user_id ) { 1466 1474 // Rehash using new hash. 1467 wp_set_password($ password, $user_id);1475 wp_set_password($slashed_password, $user_id); 1468 1476 $hash = wp_hash_password($password); 1469 1477 } 1470 1478 … … 1481 1489 1482 1490 $check = $wp_hasher->CheckPassword($password, $hash); 1483 1491 1492 if ( !$check && $user_id ) { 1493 $check = $wp_hasher->CheckPassword($slashed_password, $hash); 1494 if ( $check ) { 1495 // Rehash with correct password 1496 wp_set_password($slashed_password, $user_id); 1497 $hash = wp_hash_password($password); 1498 } 1499 } 1500 1484 1501 return apply_filters('check_password', $check, $password, $hash, $user_id); 1485 1502 } 1486 1503 endif; … … 1576 1593 function wp_set_password( $password, $user_id ) { 1577 1594 global $wpdb; 1578 1595 1579 $hash = wp_hash_password( $password);1596 $hash = wp_hash_password(stripslashes($password)); 1580 1597 $wpdb->update($wpdb->users, array('user_pass' => $hash, 'user_activation_key' => ''), array('ID' => $user_id) ); 1581 1598 1582 1599 wp_cache_delete($user_id, 'users');