Prevent an issue on windows systems which can cause the temporary directory from get_temp_dir() from returning a path containing \/. Props to SergeyBiryukov for the initial patch. Fixes #20778

git-svn-id: https://develop.svn.wordpress.org/trunk@22331 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse 2012-10-30 20:58:35 +00:00
parent 5792b83c42
commit 499f18d2c2
1 changed files with 3 additions and 3 deletions

View File

@ -1399,20 +1399,20 @@ function get_temp_dir() {
return trailingslashit(WP_TEMP_DIR);
if ( $temp )
return trailingslashit($temp);
return trailingslashit( rtrim( $temp, '\\' ) );
$is_win = ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) );
if ( function_exists('sys_get_temp_dir') ) {
$temp = sys_get_temp_dir();
if ( @is_dir( $temp ) && ( $is_win ? win_is_writable( $temp ) : @is_writable( $temp ) ) ) {
return trailingslashit( $temp );
return trailingslashit( rtrim( $temp, '\\' ) );
}
}
$temp = ini_get('upload_tmp_dir');
if ( is_dir( $temp ) && ( $is_win ? win_is_writable( $temp ) : @is_writable( $temp ) ) )
return trailingslashit($temp);
return trailingslashit( rtrim( $temp, '\\' ) );
$temp = WP_CONTENT_DIR . '/';
if ( is_dir( $temp ) && ( $is_win ? win_is_writable( $temp ) : @is_writable( $temp ) ) )