Fix edit.php row action redirects when referrers are not sent. Return false from wp_get_referer() when no referrer found. Props mitchoyoshitaka. fixes #17628

git-svn-id: http://svn.automattic.com/wordpress/trunk@19272 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2011-11-14 16:59:45 +00:00
parent 6566ac849d
commit 0ec7ae44ca
3 changed files with 11 additions and 6 deletions

View File

@ -51,6 +51,8 @@ if ( $doaction ) {
check_admin_referer('bulk-posts');
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() );
if ( ! $sendback )
$sendback = admin_url( $parent_file );
$sendback = add_query_arg( 'paged', $pagenum, $sendback );
if ( strpos($sendback, 'post.php') !== false )
$sendback = admin_url($post_new_file);

View File

@ -82,9 +82,11 @@ elseif ( isset($_POST['wp-preview']) && 'dopreview' == $_POST['wp-preview'] )
$action = 'preview';
$sendback = wp_get_referer();
if ( strpos($sendback, 'post.php') !== false || strpos($sendback, 'post-new.php') !== false ) {
$sendback = admin_url('edit.php');
$sendback .= ( !empty( $post_type ) ) ? '?post_type=' . $post_type : '';
if ( ! $sendback ||
strpos( $sendback, 'post.php' ) !== false ||
strpos( $sendback, 'post-new.php' ) !== false ) {
$sendback = admin_url( 'edit.php' );
$sendback .= ( ! empty( $post_type ) ) ? '?post_type=' . $post_type : '';
} else {
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), $sendback );
}

View File

@ -2037,7 +2037,8 @@ function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {
}
/**
* Retrieve referer from '_wp_http_referer', HTTP referer, or current page respectively.
* Retrieve referer from '_wp_http_referer' or HTTP referer. If it's the same
* as the current request URL, will return false.
*
* @package WordPress
* @subpackage Security
@ -2046,13 +2047,13 @@ function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {
* @return string|bool False on failure. Referer URL on success.
*/
function wp_get_referer() {
$ref = '';
$ref = false;
if ( ! empty( $_REQUEST['_wp_http_referer'] ) )
$ref = $_REQUEST['_wp_http_referer'];
else if ( ! empty( $_SERVER['HTTP_REFERER'] ) )
$ref = $_SERVER['HTTP_REFERER'];
if ( $ref !== $_SERVER['REQUEST_URI'] )
if ( $ref && $ref !== $_SERVER['REQUEST_URI'] )
return $ref;
return false;
}