X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/d3b1ea255664edd2deef17f900a655613d20820d..1c09677af04c9e37714e09b73eb9dbc5b2e3eb13:/wp-includes/pluggable.php diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index 6074b00f..0946f8f2 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -99,7 +99,7 @@ function get_currentuserinfo() { return; if ( ! $user = wp_validate_auth_cookie() ) { - if ( empty($_COOKIE[LOGGED_IN_COOKIE]) || !$user = wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in') ) { + if ( is_admin() || empty($_COOKIE[LOGGED_IN_COOKIE]) || !$user = wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in') ) { wp_set_current_user(0); return false; } @@ -539,6 +539,9 @@ function wp_validate_auth_cookie($cookie = '', $scheme = '') { return false; } + if ( $expiration < time() ) // AJAX/POST grace period set above + $GLOBALS['login_grace_period'] = 1; + do_action('auth_cookie_valid', $cookie_elements, $user); return $user->ID; @@ -750,7 +753,7 @@ function auth_redirect() { } } - if ( $user_id = wp_validate_auth_cookie() ) { + if ( $user_id = wp_validate_auth_cookie( '', apply_filters( 'auth_redirect_scheme', '' ) ) ) { do_action('auth_redirect', $user_id); // If the user wants ssl but the session is not ssl, redirect. @@ -821,7 +824,7 @@ function check_ajax_referer( $action = -1, $query_arg = false, $die = true ) { if ( $query_arg ) $nonce = $_REQUEST[$query_arg]; else - $nonce = $_REQUEST['_ajax_nonce'] ? $_REQUEST['_ajax_nonce'] : $_REQUEST['_wpnonce']; + $nonce = isset($_REQUEST['_ajax_nonce']) ? $_REQUEST['_ajax_nonce'] : $_REQUEST['_wpnonce']; $result = wp_verify_nonce( $nonce, $action ); @@ -862,7 +865,7 @@ function wp_redirect($location, $status = 302) { } else { if ( php_sapi_name() != 'cgi-fcgi' ) status_header($status); // This causes problems on IIS and some FastCGI setups - header("Location: $location"); + header("Location: $location", true, $status); } } endif; @@ -880,17 +883,8 @@ function wp_sanitize_redirect($location) { $location = wp_kses_no_null($location); // remove %0d and %0a from location - $strip = array('%0d', '%0a'); - $found = true; - while($found) { - $found = false; - foreach( (array) $strip as $val ) { - while(strpos($location, $val) !== false) { - $found = true; - $location = str_replace($val, '', $location); - } - } - } + $strip = array('%0d', '%0a', '%0D', '%0A'); + $location = _deep_replace($strip, $location); return $location; } endif; @@ -908,8 +902,7 @@ if ( !function_exists('wp_safe_redirect') ) : * but only used in a few places. * * @since 2.3 - * @uses apply_filters() Calls 'allowed_redirect_hosts' on an array containing - * WordPress host string and $location host string. + * @uses wp_validate_redirect() To validate the redirect is to an allowed host. * * @return void Does not return anything **/ @@ -918,6 +911,31 @@ function wp_safe_redirect($location, $status = 302) { // Need to look at the URL the way it will end up in wp_redirect() $location = wp_sanitize_redirect($location); + $location = wp_validate_redirect($location, admin_url()); + + wp_redirect($location, $status); +} +endif; + +if ( !function_exists('wp_validate_redirect') ) : +/** + * Validates a URL for use in a redirect. + * + * Checks whether the $location is using an allowed host, if it has an absolute + * path. A plugin can therefore set or remove allowed host(s) to or from the + * list. + * + * If the host is not allowed, then the redirect is to $default supplied + * + * @since 2.8.1 + * @uses apply_filters() Calls 'allowed_redirect_hosts' on an array containing + * WordPress host string and $location host string. + * + * @param string $location The redirect to validate + * @param string $default The value to return is $location is not allowed + * @return string redirect-sanitized URL + **/ +function wp_validate_redirect($location, $default = '') { // browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//' if ( substr($location, 0, 2) == '//' ) $location = 'http:' . $location; @@ -931,9 +949,9 @@ function wp_safe_redirect($location, $status = 302) { $allowed_hosts = (array) apply_filters('allowed_redirect_hosts', array($wpp['host']), isset($lp['host']) ? $lp['host'] : ''); if ( isset($lp['host']) && ( !in_array($lp['host'], $allowed_hosts) && $lp['host'] != strtolower($wpp['host'])) ) - $location = admin_url(); + $location = $default; - wp_redirect($location, $status); + return $location; } endif; @@ -958,8 +976,10 @@ function wp_notify_postauthor($comment_id, $comment_type='') { if ('' == $user->user_email) return false; // If there's no email to send the comment to $comment_author_domain = @gethostbyaddr($comment->comment_author_IP); - - $blogname = get_option('blogname'); + + // The blogname option is escaped with esc_html on the way into the database in sanitize_option + // we want to reverse this for the plain text arena of emails. + $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); if ( empty( $comment_type ) ) $comment_type = 'comment'; @@ -983,7 +1003,7 @@ function wp_notify_postauthor($comment_id, $comment_type='') { $notify_message .= sprintf( __('URL : %s'), $comment->comment_author_url ) . "\r\n"; $notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; $notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n"; - /* translators: 1: blog name, 2: post title */ + /* translators: 1: blog name, 2: post title */ $subject = sprintf( __('[%1$s] Trackback: "%2$s"'), $blogname, $post->post_title ); } elseif ('pingback' == $comment_type) { /* translators: 1: post id, 2: post title */ @@ -997,8 +1017,11 @@ function wp_notify_postauthor($comment_id, $comment_type='') { $subject = sprintf( __('[%1$s] Pingback: "%2$s"'), $blogname, $post->post_title ); } $notify_message .= get_permalink($comment->comment_post_ID) . "#comments\r\n\r\n"; - $notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=cdc&c=$comment_id") ) . "\r\n"; - $notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=cdc&dt=spam&c=$comment_id") ) . "\r\n"; + if ( EMPTY_TRASH_DAYS ) + $notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n"; + else + $notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=delete&c=$comment_id") ) . "\r\n"; + $notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=spam&c=$comment_id") ) . "\r\n"; $wp_email = 'wordpress@' . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])); @@ -1049,7 +1072,11 @@ function wp_notify_moderator($comment_id) { $comment_author_domain = @gethostbyaddr($comment->comment_author_IP); $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'"); - + + // The blogname option is escaped with esc_html on the way into the database in sanitize_option + // we want to reverse this for the plain text arena of emails. + $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); + switch ($comment->comment_type) { case 'trackback': @@ -1077,15 +1104,18 @@ function wp_notify_moderator($comment_id) { break; } - $notify_message .= sprintf( __('Approve it: %s'), admin_url("comment.php?action=mac&c=$comment_id") ) . "\r\n"; - $notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=cdc&c=$comment_id") ) . "\r\n"; - $notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=cdc&dt=spam&c=$comment_id") ) . "\r\n"; + $notify_message .= sprintf( __('Approve it: %s'), admin_url("comment.php?action=approve&c=$comment_id") ) . "\r\n"; + if ( EMPTY_TRASH_DAYS ) + $notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n"; + else + $notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=delete&c=$comment_id") ) . "\r\n"; + $notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=spam&c=$comment_id") ) . "\r\n"; $notify_message .= sprintf( _n('Currently %s comment is waiting for approval. Please visit the moderation panel:', 'Currently %s comments are waiting for approval. Please visit the moderation panel:', $comments_waiting), number_format_i18n($comments_waiting) ) . "\r\n"; $notify_message .= admin_url("edit-comments.php?comment_status=moderated") . "\r\n"; - $subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), get_option('blogname'), $post->post_title ); + $subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), $blogname, $post->post_title ); $admin_email = get_option('admin_email'); $message_headers = ''; @@ -1112,7 +1142,10 @@ function wp_password_change_notification(&$user) { // but check to see if it's the admin whose password we're changing, and skip this if ( $user->user_email != get_option('admin_email') ) { $message = sprintf(__('Password Lost and Changed for user: %s'), $user->user_login) . "\r\n"; - wp_mail(get_option('admin_email'), sprintf(__('[%s] Password Lost/Changed'), get_option('blogname')), $message); + // The blogname option is escaped with esc_html on the way into the database in sanitize_option + // we want to reverse this for the plain text arena of emails. + $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); + wp_mail(get_option('admin_email'), sprintf(__('[%s] Password Lost/Changed'), $blogname), $message); } } endif; @@ -1131,12 +1164,16 @@ function wp_new_user_notification($user_id, $plaintext_pass = '') { $user_login = stripslashes($user->user_login); $user_email = stripslashes($user->user_email); + + // The blogname option is escaped with esc_html on the way into the database in sanitize_option + // we want to reverse this for the plain text arena of emails. + $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); - $message = sprintf(__('New user registration on your blog %s:'), get_option('blogname')) . "\r\n\r\n"; + $message = sprintf(__('New user registration on your blog %s:'), $blogname) . "\r\n\r\n"; $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n"; - @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), get_option('blogname')), $message); + @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message); if ( empty($plaintext_pass) ) return; @@ -1145,7 +1182,7 @@ function wp_new_user_notification($user_id, $plaintext_pass = '') { $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n"; $message .= wp_login_url() . "\r\n"; - wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_option('blogname')), $message); + wp_mail($user_email, sprintf(__('[%s] Your username and password'), $blogname), $message); } endif; @@ -1752,4 +1789,3 @@ function wp_text_diff( $left_string, $right_string, $args = null ) { } endif; -?>