From d2416ca93a1ed89aa84b90de284be57167530cda Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Thu, 8 Oct 2015 03:09:24 +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 Built from https://develop.svn.wordpress.org/trunk@34932 git-svn-id: http://core.svn.wordpress.org/trunk@34897 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/version.php | 2 +- wp-login.php | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/wp-includes/version.php b/wp-includes/version.php index 1b33670a2f..4c57bc0701 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34931'; +$wp_version = '4.4-alpha-34932'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. diff --git a/wp-login.php b/wp-login.php index 13adb3f141..1f9e334bf3 100644 --- a/wp-login.php +++ b/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() );