Correctly set the `secure` flag on the post password cookie based on the scheme of the referring URL, if it's available, instead of the home URL.

Fixes #29641


git-svn-id: https://develop.svn.wordpress.org/trunk@34932 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
John Blackbourn 2015-10-08 03:08:05 +00:00
parent 855991c578
commit 9b156ee2a9
1 changed files with 6 additions and 1 deletions

View File

@ -440,7 +440,12 @@ case 'postpass' :
* @param int $expires The expiry time, as passed to setcookie().
*/
$expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS );
$secure = ( 'https' === parse_url( home_url(), PHP_URL_SCHEME ) );
$referer = wp_get_referer();
if ( $referer ) {
$secure = ( 'https' === parse_url( $referer, PHP_URL_SCHEME ) );
} else {
$secure = false;
}
setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure );
wp_safe_redirect( wp_get_referer() );