Skip to content

Commit

Permalink
Always exit after wp_redirect. props filosofo, fixes #15518.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.automattic.com/wordpress/trunk@16847 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
nacin committed Dec 9, 2010
1 parent 0036c52 commit a717edc
Show file tree
Hide file tree
Showing 29 changed files with 64 additions and 36 deletions.
8 changes: 6 additions & 2 deletions wp-admin/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,17 @@
if ( ! current_user_can('import') )
wp_die(__('You are not allowed to import.'));

if ( validate_file($importer) )
if ( validate_file($importer) ) {
wp_redirect( admin_url( 'import.php?invalid=' . $importer ) );
exit;
}

// Allow plugins to define importers as well
if ( !isset($wp_importers) || !isset($wp_importers[$importer]) || ! is_callable($wp_importers[$importer][2])) {
if (! file_exists(ABSPATH . "wp-admin/import/$importer.php"))
if (! file_exists(ABSPATH . "wp-admin/import/$importer.php")) {
wp_redirect( admin_url( 'import.php?invalid=' . $importer ) );
exit;
}
include(ABSPATH . "wp-admin/import/$importer.php");
}

Expand Down
4 changes: 1 addition & 3 deletions wp-admin/includes/ms.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,12 +507,10 @@ function redirect_user_to_blog() {

if ( is_object( $blog ) ) {
wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) ); // redirect and count to 5, "just in case"
exit;
} else {
wp_redirect( user_admin_url( '?c=' . $c ) ); // redirect and count to 5, "just in case"
}

wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
exit;
}
add_action( 'admin_page_access_denied', 'redirect_user_to_blog', 99 );

Expand Down
1 change: 1 addition & 0 deletions wp-admin/link-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
}

wp_redirect( add_query_arg('deleted', count( $bulklinks ), admin_url( 'link-manager.php' ) ) );
exit;
}
} elseif ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), stripslashes( $_SERVER['REQUEST_URI'] ) ) );
Expand Down
1 change: 1 addition & 0 deletions wp-admin/media-upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
$location .= '?message=3';

wp_redirect( admin_url($location) );
exit;
}

$title = __('Upload New Media');
Expand Down
1 change: 1 addition & 0 deletions wp-admin/moderation.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
*/
require_once('../wp-load.php');
wp_redirect( admin_url('edit-comments.php?comment_status=moderated') );
exit;
?>
4 changes: 3 additions & 1 deletion wp-admin/ms-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@

require_once( './admin.php' );

wp_redirect( network_admin_url() );
wp_redirect( network_admin_url() );
exit;
?>
4 changes: 3 additions & 1 deletion wp-admin/ms-edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@

require_once( './admin.php' );

wp_redirect( network_admin_url() );
wp_redirect( network_admin_url() );
exit;
?>
5 changes: 4 additions & 1 deletion wp-admin/ms-sites.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@

require_once( './admin.php' );

wp_redirect( network_admin_url('sites.php') );
wp_redirect( network_admin_url('sites.php') );
exit;

?>
4 changes: 3 additions & 1 deletion wp-admin/ms-themes.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@

require_once( './admin.php' );

wp_redirect( network_admin_url('themes.php') );
wp_redirect( network_admin_url('themes.php') );
exit;
?>
5 changes: 4 additions & 1 deletion wp-admin/ms-upgrade-network.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@

require_once('admin.php');

wp_redirect( network_admin_url('upgrade.php') );
wp_redirect( network_admin_url('upgrade.php') );
exit;

?>
4 changes: 3 additions & 1 deletion wp-admin/ms-users.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@

require_once( './admin.php' );

wp_redirect( network_admin_url('users.php') );
wp_redirect( network_admin_url('users.php') );
exit;
?>
5 changes: 3 additions & 2 deletions wp-admin/network/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
if ( ! is_multisite() )
wp_die( __( 'Multisite support is not enabled.' ) );

if ( ! is_main_site() )
if ( ! is_main_site() ) {
wp_redirect( network_admin_url() );

exit;
}
?>
4 changes: 3 additions & 1 deletion wp-admin/network/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
if ( ! is_multisite() )
wp_die( __( 'Multisite support is not enabled.' ) );

if ( empty( $_GET['action'] ) )
if ( empty( $_GET['action'] ) ) {
wp_redirect( admin_url( 'index.php' ) );
exit;
}

function confirm_delete_users( $users ) {
$current_user = wp_get_current_user();
Expand Down
1 change: 1 addition & 0 deletions wp-admin/network/site-info.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

restore_current_blog();
wp_redirect( add_query_arg( array( 'update' => 'updated', 'id' => $id ), 'site-info.php') );
exit;
}

if ( isset($_GET['update']) ) {
Expand Down
3 changes: 2 additions & 1 deletion wp-admin/network/site-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
do_action( 'wpmu_update_blog_options' );
restore_current_blog();
wp_redirect( add_query_arg( array( 'update' => 'updated', 'id' => $id ), 'site-options.php') );
exit;
}

if ( isset($_GET['update']) ) {
Expand Down Expand Up @@ -131,4 +132,4 @@

</div>
<?php
require('../admin-footer.php');
require('../admin-footer.php');
2 changes: 1 addition & 1 deletion wp-admin/network/site-users.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,4 @@
</form>
</div>
<?php
require('../admin-footer.php');
require('../admin-footer.php');
1 change: 0 additions & 1 deletion wp-admin/plugin-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
update_option('recently_activated', array($file => time()) + (array)get_option('recently_activated'));

wp_redirect(add_query_arg('_wpnonce', wp_create_nonce('edit-plugin-test_' . $file), "plugin-editor.php?file=$file&liveupdate=1&scrollto=$scrollto&networkwide=" . $network_wide));
exit;
}
wp_redirect( self_admin_url("plugin-editor.php?file=$file&a=te&scrollto=$scrollto") );
} else {
Expand Down
3 changes: 2 additions & 1 deletion wp-admin/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function redirect_post($post_id = '') {
}

wp_redirect( apply_filters( 'redirect_post_location', $location, $post_id ) );
exit;
}

if ( isset( $_POST['deletepost'] ) )
Expand Down Expand Up @@ -265,7 +266,7 @@ function redirect_post($post_id = '') {
break;

default:
wp_redirect( admin_url('edit.php') );
wp_redirect( admin_url('edit.php') );
exit();
break;
} // end switch
Expand Down
2 changes: 2 additions & 0 deletions wp-admin/update-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ function do_dismiss_core_update() {
return;
dismiss_core_update( $update );
wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
exit;
}

function do_undismiss_core_update() {
Expand All @@ -376,6 +377,7 @@ function do_undismiss_core_update() {
return;
undismiss_core_update( $version, $locale );
wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
exit;
}

function no_update_actions($actions) {
Expand Down
5 changes: 3 additions & 2 deletions wp-admin/user/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

require_once( dirname(dirname(__FILE__)) . '/admin.php');

if ( ! is_main_site() )
if ( ! is_main_site() ) {
wp_redirect( user_admin_url() );

exit;
}
?>
4 changes: 2 additions & 2 deletions wp-atom.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

require( './wp-load.php' );
wp_redirect( get_bloginfo( 'atom_url' ), 301 );

?>
exit;
?>
2 changes: 1 addition & 1 deletion wp-comments-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,5 @@
$location = apply_filters('comment_post_redirect', $location, $comment);

wp_redirect($location);

exit;
?>
4 changes: 2 additions & 2 deletions wp-commentsrss2.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

require( './wp-load.php' );
wp_redirect( get_bloginfo( 'comments_rss2_url' ), 301 );

?>
exit;
?>
4 changes: 2 additions & 2 deletions wp-feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

require( './wp-load.php' );
wp_redirect( get_bloginfo( get_default_feed() . '_url' ), 301 );

?>
exit;
?>
3 changes: 2 additions & 1 deletion wp-pass.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@
setcookie('wp-postpass_' . COOKIEHASH, $_POST['post_password'], time() + 864000, COOKIEPATH);

wp_safe_redirect(wp_get_referer());
?>
exit;
?>
4 changes: 2 additions & 2 deletions wp-rdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

require( './wp-load.php' );
wp_redirect( get_bloginfo( 'rdf_url' ), 301 );

?>
exit;
?>
4 changes: 2 additions & 2 deletions wp-register.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@

require('./wp-load.php');
wp_redirect( site_url('wp-login.php?action=register') );

?>
exit;
?>
4 changes: 2 additions & 2 deletions wp-rss.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

require( './wp-load.php' );
wp_redirect( get_bloginfo( 'rss_url' ), 301 );

?>
exit;
?>
4 changes: 2 additions & 2 deletions wp-rss2.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

require( './wp-load.php' );
wp_redirect( get_bloginfo( 'rss2_url' ), 301 );

?>
exit;
?>

0 comments on commit a717edc

Please sign in to comment.