Changeset 6751 for branches/2.0/wp-includes/pluggable-functions.php
- Timestamp:
- 02/07/2008 06:23:51 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0/wp-includes/pluggable-functions.php
r5993 r6751 260 260 global $is_IIS; 261 261 262 $location = apply_filters('wp_redirect', $location, $status); 263 264 if ( !$location ) // allows the wp_redirect filter to cancel a redirect 265 return false; 266 267 $location = wp_sanitize_redirect($location); 268 269 if ( $is_IIS ) { 270 header("Refresh: 0;url=$location"); 271 } else { 272 if ( php_sapi_name() != 'cgi-fcgi' ) 273 status_header($status); // This causes problems on IIS and some FastCGI setups 274 header("Location: $location"); 275 } 276 } 277 endif; 278 279 if ( !function_exists('wp_sanitize_redirect') ) : 280 /** 281 * sanitizes a URL for use in a redirect 282 * @return string redirect-sanitized URL 283 **/ 284 function wp_sanitize_redirect($location) { 262 285 $location = preg_replace('|[^a-z0-9-~+_.?#=&;,/:%]|i', '', $location); 286 $location = wp_kses_no_null($location); 263 287 264 288 // remove %0d and %0a from location … … 274 298 } 275 299 } 276 277 if ( $is_IIS ) { 278 header("Refresh: 0;url=$location"); 279 } else { 280 if ( php_sapi_name() != 'cgi-fcgi' ) 281 status_header($status); // This causes problems on IIS and some FastCGI setups 282 header("Location: $location"); 283 } 300 return $location; 301 } 302 endif; 303 304 if ( !function_exists('wp_safe_redirect') ) : 305 /** 306 * performs a safe (local) redirect, using wp_redirect() 307 * @return void 308 **/ 309 function wp_safe_redirect($location, $status = 302) { 310 311 // Need to look at the URL the way it will end up in wp_redirect() 312 $location = wp_sanitize_redirect($location); 313 314 // browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//' 315 if ( substr($location, 0, 2) == '//' ) 316 $location = 'http:' . $location; 317 318 $lp = parse_url($location); 319 $wpp = parse_url(get_option('home')); 320 321 $allowed_hosts = (array) apply_filters('allowed_redirect_hosts', array($wpp['host'])); 322 323 if ( isset($lp['host']) && ( !in_array($lp['host'], $allowed_hosts) && $lp['host'] != strtolower($wpp['host'])) ) 324 $location = get_option('siteurl') . '/wp-admin/'; 325 326 wp_redirect($location, $status); 284 327 } 285 328 endif;
Note: See TracChangeset
for help on using the changeset viewer.