From 9b156ee2a99d1f4a03f23d6c9669c8a792ed5682 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Thu, 8 Oct 2015 03:08:05 +0000 Subject: [PATCH] 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 --- src/wp-login.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wp-login.php b/src/wp-login.php index 13adb3f141..1f9e334bf3 100644 --- a/src/wp-login.php +++ b/src/wp-login.php @@ -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() );