WordPress.org

Make WordPress Core

Changeset 6131


Ignore:
Timestamp:
09/18/07 22:23:16 (7 years ago)
Author:
markjaquith
Message:

Introducing wp_safe_redirect(). fixes #4606 for trunk

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/pluggable.php

    r6094 r6131  
    397397        header("Location: $location"); 
    398398    } 
     399} 
     400endif; 
     401 
     402if ( !function_exists('wp_safe_redirect') ) : 
     403/** 
     404 * performs a safe (local) redirect, using wp_redirect() 
     405 * @return void 
     406 **/ 
     407function wp_safe_redirect($location, $status = 302) { 
     408    if ( $location{0} == '/' ) { 
     409        if ( $location{1} == '/' ) 
     410            $location = get_option('home') . '/'; 
     411    } else { 
     412        if ( substr($location, 0, strlen(get_option('home'))) != get_option('home') ) 
     413            $location = get_option('home') . '/'; 
     414    } 
     415 
     416    wp_redirect($location, $status); 
    399417} 
    400418endif; 
  • trunk/wp-login.php

    r6026 r6131  
    7979        $redirect_to = $_REQUEST['redirect_to']; 
    8080 
    81     wp_redirect($redirect_to); 
     81    wp_safe_redirect($redirect_to); 
    8282    exit(); 
    8383 
     
    325325                wp_setcookie($user_login, $user_pass, false, '', '', $rememberme); 
    326326            do_action('wp_login', $user_login); 
    327             wp_redirect($redirect_to); 
     327            wp_safe_redirect($redirect_to); 
    328328            exit(); 
    329329        } else { 
  • trunk/wp-pass.php

    r3921 r6131  
    88setcookie('wp-postpass_' . COOKIEHASH, $_POST['post_password'], time() + 864000, COOKIEPATH); 
    99 
    10 wp_redirect(wp_get_referer()); 
     10wp_safe_redirect(wp_get_referer()); 
    1111?> 
Note: See TracChangeset for help on using the changeset viewer.