From 37d88adaffbe13e7c5dbc5fd7afea11b22baa429 Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 25 Aug 2008 21:09:26 +0000 Subject: [PATCH] Don't ignore scheme when cookie value is empty. Props bendalton. fixes #7521 git-svn-id: http://svn.automattic.com/wordpress/trunk@8731 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/pluggable.php | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index 8c53f7ac9b..ad18ea5012 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -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 * @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) ) { do_action('auth_cookie_malformed', $cookie, $scheme); 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 * @return array Authentication cookie components */ -function wp_parse_auth_cookie($cookie = '', $scheme = 'auth') { +function wp_parse_auth_cookie($cookie = '', $scheme = '') { if ( empty($cookie) ) { - if ( is_ssl() ) { - $cookie_name = SECURE_AUTH_COOKIE; - $scheme = 'secure_auth'; - } else { - $cookie_name = AUTH_COOKIE; - $scheme = 'auth'; - } + switch ($scheme){ + case 'auth': + $cookie_name = AUTH_COOKIE; + break; + case 'secure_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]) ) return false;