Changeset 30468
- Timestamp:
- 11/20/2014 04:05:10 PM (11 years ago)
- Location:
- branches/3.9
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
src/wp-includes/class-phpass.php (modified) (2 diffs)
-
tests/phpunit/tests/auth.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/3.9
-
branches/3.9/src/wp-includes/class-phpass.php
r26868 r30468 215 215 function HashPassword($password) 216 216 { 217 if ( strlen( $password ) > 4096 ) { 218 return '*'; 219 } 220 217 221 $random = ''; 218 222 … … 250 254 function CheckPassword($password, $stored_hash) 251 255 { 256 if ( strlen( $password ) > 4096 ) { 257 return false; 258 } 259 252 260 $hash = $this->crypt_private($password, $stored_hash); 253 261 if ($hash[0] == '*') -
branches/3.9/tests/phpunit/tests/auth.php
r25709 r30468 3 3 /** 4 4 * @group pluggable 5 * @group auth 5 6 */ 6 7 class Tests_Auth extends WP_UnitTestCase { … … 92 93 $this->assertTrue( wp_check_password( 'pass with vertial tab o_O', wp_hash_password( $password ) ) ); 93 94 } 95 96 function test_password_length_limit() { 97 $passwords = array( 98 str_repeat( 'a', 4095 ), // short 99 str_repeat( 'a', 4096 ), // limit 100 str_repeat( 'a', 4097 ), // long 101 ); 102 103 $user_id = $this->factory->user->create( array( 'user_login' => 'password-length-test' ) ); 104 105 wp_set_password( $passwords[1], $user_id ); 106 $user = get_user_by( 'id', $user_id ); 107 // phpass hashed password 108 $this->assertStringStartsWith( '$P$', $user->data->user_pass ); 109 110 $user = wp_authenticate( 'password-length-test', $passwords[0] ); 111 // Wrong Password 112 $this->assertInstanceOf( 'WP_Error', $user ); 113 114 $user = wp_authenticate( 'password-length-test', $passwords[1] ); 115 $this->assertInstanceOf( 'WP_User', $user ); 116 $this->assertEquals( $user_id, $user->ID ); 117 118 $user = wp_authenticate( 'password-length-test', $passwords[2] ); 119 // Wrong Password 120 $this->assertInstanceOf( 'WP_Error', $user ); 121 122 123 wp_set_password( $passwords[2], $user_id ); 124 $user = get_user_by( 'id', $user_id ); 125 // Password broken by setting it to be too long. 126 $this->assertEquals( '*', $user->data->user_pass ); 127 128 $user = wp_authenticate( 'password-length-test', $passwords[0] ); 129 // Wrong Password 130 $this->assertInstanceOf( 'WP_Error', $user ); 131 132 $user = wp_authenticate( 'password-length-test', $passwords[1] ); 133 // Wrong Password 134 $this->assertInstanceOf( 'WP_Error', $user ); 135 136 $user = wp_authenticate( 'password-length-test', $passwords[2] ); 137 // Password broken by setting it to be too long. 138 $this->assertInstanceOf( 'WP_Error', $user ); 139 } 94 140 }
Note: See TracChangeset
for help on using the changeset viewer.