Make WordPress Core

Changeset 24466


Ignore:
Timestamp:
06/21/2013 03:00:26 AM (13 years ago)
Author:
nacin
Message:

Validate post password hash.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post-template.php

    r24377 r24466  
    589589 */
    590590function post_password_required( $post = null ) {
    591         global $wp_hasher;
    592 
    593591        $post = get_post($post);
    594592
     
    599597                return true;
    600598
    601         if ( empty( $wp_hasher ) ) {
    602                 require_once( ABSPATH . 'wp-includes/class-phpass.php');
    603                 // By default, use the portable hash from phpass
    604                 $wp_hasher = new PasswordHash(8, true);
    605         }
     599        require_once ABSPATH . 'wp-includes/class-phpass.php';
     600        $hasher = new PasswordHash( 8, true );
    606601
    607602        $hash = wp_unslash( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] );
    608 
    609         return ! $wp_hasher->CheckPassword( $post->post_password, $hash );
     603        if ( 0 !== strpos( $hash, '$P$B' ) )
     604                return true;
     605
     606        return ! $hasher->CheckPassword( $post->post_password, $hash );
    610607}
    611608
  • trunk/wp-login.php

    r24317 r24466  
    408408
    409409case 'postpass' :
    410         if ( empty( $wp_hasher ) ) {
    411                 require_once( ABSPATH . 'wp-includes/class-phpass.php' );
    412                 // By default, use the portable hash from phpass
    413                 $wp_hasher = new PasswordHash(8, true);
    414         }
     410        require_once ABSPATH . 'wp-includes/class-phpass.php';
     411        $hasher = new PasswordHash( 8, true );
    415412
    416413        // 10 days
    417         setcookie( 'wp-postpass_' . COOKIEHASH, $wp_hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), time() + 10 * DAY_IN_SECONDS, COOKIEPATH );
     414        setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), time() + 10 * DAY_IN_SECONDS, COOKIEPATH );
    418415
    419416        wp_safe_redirect( wp_get_referer() );
Note: See TracChangeset for help on using the changeset viewer.