| @@ -9,9 +9,9 @@ | ||
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Implementation of AEF Forum converter. |
| 12 | 12 | * |
| 13 | - * @since 2.5.0 bbPress (r5139) | |
| 13 | + * @since 2.5.0 bbPress (r5140) | |
| 14 | 14 | * |
| 15 | 15 | * @link Codex Docs https://codex.bbpress.org/import-forums/aef |
| 16 | 16 | */ |
| 17 | 17 | class AEF extends BBP_Converter_Base { |
| @@ -449,9 +449,9 @@ | ||
| 449 | 449 | ); |
| 450 | 450 | |
| 451 | 451 | // User password verify class (Stored in usermeta for verifying password) |
| 452 | 452 | $this->field_map[] = array( |
| 453 | - 'to_type' => 'users', | |
| 453 | + 'to_type' => 'user', | |
| 454 | 454 | 'to_fieldname' => '_bbp_class', |
| 455 | 455 | 'default' => 'AEF' |
| 456 | 456 | ); |
| 457 | 457 | |
| @@ -577,9 +577,9 @@ | ||
| 577 | 577 | */ |
| 578 | 578 | public function callback_savepass( $field, $row ) { |
| 579 | 579 | $pass_array = array( |
| 580 | 580 | 'hash' => $field, |
| 581 | - 'salt' => $row['salt'] | |
| 581 | + 'salt' => isset( $row['salt'] ) ? wp_slash( (string) $row['salt'] ) : '' | |
| 582 | 582 | ); |
| 583 | 583 | |
| 584 | 584 | return $pass_array; |
| 585 | 585 | } |
| @@ -590,26 +590,30 @@ | ||
| 590 | 590 | */ |
| 591 | 591 | public function authenticate_pass( $password, $serialized_pass ) { |
| 592 | 592 | |
| 593 | 593 | // Unserialize the password, with safeguards |
| 594 | - $pass_array = unserialize( | |
| 595 | - $serialized_pass, | |
| 596 | - array( | |
| 597 | - 'allowed_classes' => false, | |
| 598 | - 'max_depth' => 1 | |
| 599 | - ) | |
| 600 | - ); | |
| 594 | + $pass_array = $this->unserialize_pass( $serialized_pass ); | |
| 601 | 595 | |
| 602 | - // Bail if missing values | |
| 603 | - if ( ! is_array( $pass_array ) || ! isset( $pass_array['hash'], $pass_array['salt'] ) ) { | |
| 596 | + // Bail if missing or invalid values | |
| 597 | + if ( ! is_string( $password ) || ! is_array( $pass_array ) || ! isset( $pass_array['hash'], $pass_array['salt'] ) || ! is_string( $pass_array['hash'] ) || ! is_string( $pass_array['salt'] ) ) { | |
| 604 | 598 | return false; |
| 605 | 599 | } |
| 606 | 600 | |
| 607 | - // Return comparison | |
| 608 | - return hash_equals( | |
| 609 | - $pass_array['hash'], | |
| 610 | - md5( md5( $password ) . $pass_array['salt'] ) | |
| 611 | - ); | |
| 601 | + // AEF encodes and escapes the submitted password before hashing it | |
| 602 | + foreach ( array( 'UTF-8', 'ISO-8859-1' ) as $charset ) { | |
| 603 | + $legacy_password = addslashes( htmlentities( $password, ENT_QUOTES, $charset ) ); | |
| 604 | + | |
| 605 | + // Do not let invalid input collapse to an empty password | |
| 606 | + if ( ( '' === $legacy_password ) && ( '' !== $password ) ) { | |
| 607 | + continue; | |
| 608 | + } | |
| 609 | + | |
| 610 | + if ( hash_equals( $pass_array['hash'], md5( $pass_array['salt'] . $legacy_password ) ) ) { | |
| 611 | + return true; | |
| 612 | + } | |
| 613 | + } | |
| 614 | + | |
| 615 | + return false; | |
| 612 | 616 | } |
| 613 | 617 | |
| 614 | 618 | /** |
| 615 | 619 | * Translate the forum status from AEF v1.0.9 numerics to WordPress's strings. |