Move the trim() from wp_set_password() to inside wp_hash_password().

props rpattillo, joehoyle.
fixes #24973. see #23494.


git-svn-id: https://develop.svn.wordpress.org/trunk@25709 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin
2013-10-07 13:53:09 +00:00
parent f4227afa2b
commit fc1438c8bc
2 changed files with 29 additions and 3 deletions

View File

@@ -44,7 +44,7 @@ class Tests_Auth extends WP_UnitTestCase {
$this->assertEquals( false, wp_validate_auth_cookie( $cookie, 'bar' ) );
}
/*
/**
* @ticket 23494
*/
function test_password_trimming() {
@@ -65,4 +65,30 @@ class Tests_Auth extends WP_UnitTestCase {
$this->assertEquals( $another_user, $authed_user->ID );
}
}
/**
* Test wp_hash_password trims whitespace
*
* This is similar to test_password_trimming but tests the "lower level"
* wp_hash_password function
*
* @ticket 24973
*/
function test_wp_hash_password_trimming() {
$password = ' pass with leading whitespace';
$this->assertTrue( wp_check_password( 'pass with leading whitespace', wp_hash_password( $password ) ) );
$password = 'pass with trailing whitespace ';
$this->assertTrue( wp_check_password( 'pass with trailing whitespace', wp_hash_password( $password ) ) );
$password = ' pass with whitespace ';
$this->assertTrue( wp_check_password( 'pass with whitespace', wp_hash_password( $password ) ) );
$password = "pass with new line \n";
$this->assertTrue( wp_check_password( 'pass with new line', wp_hash_password( $password ) ) );
$password = "pass with vertial tab o_O\x0B";
$this->assertTrue( wp_check_password( 'pass with vertial tab o_O', wp_hash_password( $password ) ) );
}
}