mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Hash post password in cookies. fixes #19797
git-svn-id: https://develop.svn.wordpress.org/trunk@19728 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -558,18 +558,25 @@ function get_body_class( $class = '' ) {
|
||||
* @return bool false if a password is not required or the correct password cookie is present, true otherwise.
|
||||
*/
|
||||
function post_password_required( $post = null ) {
|
||||
global $wp_hasher;
|
||||
|
||||
$post = get_post($post);
|
||||
|
||||
if ( empty($post->post_password) )
|
||||
if ( empty( $post->post_password ) )
|
||||
return false;
|
||||
|
||||
if ( !isset($_COOKIE['wp-postpass_' . COOKIEHASH]) )
|
||||
if ( ! isset( $_COOKIE['wp-postpass_' . COOKIEHASH] ) )
|
||||
return true;
|
||||
|
||||
if ( stripslashes( $_COOKIE['wp-postpass_' . COOKIEHASH] ) != $post->post_password )
|
||||
return true;
|
||||
if ( empty( $wp_hasher ) ) {
|
||||
require_once( ABSPATH . 'wp-includes/class-phpass.php');
|
||||
// By default, use the portable hash from phpass
|
||||
$wp_hasher = new PasswordHash(8, true);
|
||||
}
|
||||
|
||||
return false;
|
||||
$hash = stripslashes( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] );
|
||||
|
||||
return ! $wp_hasher->CheckPassword( $post->post_password, $hash );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user