Don't ignore scheme when cookie value is empty. Props bendalton. fixes #7521

git-svn-id: https://develop.svn.wordpress.org/trunk@8731 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2008-08-25 21:09:26 +00:00
parent 00e2cd0917
commit 5725b0ae44

View File

@ -484,7 +484,7 @@ if ( !function_exists('wp_validate_auth_cookie') ) :
* @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in * @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
* @return bool|int False if invalid cookie, User ID if valid. * @return bool|int False if invalid cookie, User ID if valid.
*/ */
function wp_validate_auth_cookie($cookie = '', $scheme = 'auth') { function wp_validate_auth_cookie($cookie = '', $scheme = '') {
if ( ! $cookie_elements = wp_parse_auth_cookie($cookie, $scheme) ) { if ( ! $cookie_elements = wp_parse_auth_cookie($cookie, $scheme) ) {
do_action('auth_cookie_malformed', $cookie, $scheme); do_action('auth_cookie_malformed', $cookie, $scheme);
return false; return false;
@ -559,15 +559,27 @@ if ( !function_exists('wp_parse_auth_cookie') ) :
* @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in * @param string $scheme Optional. The cookie scheme to use: auth, secure_auth, or logged_in
* @return array Authentication cookie components * @return array Authentication cookie components
*/ */
function wp_parse_auth_cookie($cookie = '', $scheme = 'auth') { function wp_parse_auth_cookie($cookie = '', $scheme = '') {
if ( empty($cookie) ) { if ( empty($cookie) ) {
if ( is_ssl() ) { switch ($scheme){
$cookie_name = SECURE_AUTH_COOKIE; case 'auth':
$scheme = 'secure_auth'; $cookie_name = AUTH_COOKIE;
} else { break;
$cookie_name = AUTH_COOKIE; case 'secure_auth':
$scheme = 'auth'; $cookie_name = SECURE_AUTH_COOKIE;
} break;
case "logged_in":
$cookie_name = LOGGED_IN_COOKIE;
break;
default:
if ( is_ssl() ) {
$cookie_name = SECURE_AUTH_COOKIE;
$scheme = 'secure_auth';
} else {
$cookie_name = AUTH_COOKIE;
$scheme = 'auth';
}
}
if ( empty($_COOKIE[$cookie_name]) ) if ( empty($_COOKIE[$cookie_name]) )
return false; return false;