WordPress.org

Make WordPress Core

Ticket #17628: 17628.diff

File 17628.diff, 2.0 KB (added by mitchoyoshitaka, 3 years ago)
  • wp-includes/functions.php

     
    20382038} 
    20392039 
    20402040/** 
    2041  * Retrieve referer from '_wp_http_referer', HTTP referer, or current page respectively. 
     2041 * Retrieve referer from '_wp_http_referer' or HTTP referer. If it's the same 
     2042 * as the current request URL, will return false. 
    20422043 * 
    20432044 * @package WordPress 
    20442045 * @subpackage Security 
     
    20472048 * @return string|bool False on failure. Referer URL on success. 
    20482049 */ 
    20492050function wp_get_referer() { 
    2050         $ref = ''; 
     2051        $ref = false; 
    20512052        if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) 
    20522053                $ref = $_REQUEST['_wp_http_referer']; 
    20532054        else if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) 
    20542055                $ref = $_SERVER['HTTP_REFERER']; 
    20552056 
    2056         if ( $ref !== $_SERVER['REQUEST_URI'] ) 
     2057        if ( $ref && $ref !== $_SERVER['REQUEST_URI'] ) 
    20572058                return $ref; 
    20582059        return false; 
    20592060} 
  • wp-admin/post.php

     
    9494        $action = 'preview'; 
    9595 
    9696$sendback = wp_get_referer(); 
    97 if ( strpos($sendback, 'post.php') !== false || strpos($sendback, 'post-new.php') !== false ) { 
     97if ( !$sendback || 
     98     strpos($sendback, 'post.php') !== false || 
     99     strpos($sendback, 'post-new.php') !== false ) { 
    98100        $sendback = admin_url('edit.php'); 
    99101        $sendback .= ( !empty( $post_type ) ) ? '?post_type=' . $post_type : ''; 
    100102} else { 
  • wp-admin/edit.php

     
    5151        check_admin_referer('bulk-posts'); 
    5252 
    5353        $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() ); 
     54        if ( !$sendback ) 
     55                $sendback = admin_url($parent_file); 
    5456        $sendback = add_query_arg( 'paged', $pagenum, $sendback ); 
    5557        if ( strpos($sendback, 'post.php') !== false ) 
    5658                $sendback = admin_url($post_new_file);