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: http://core.svn.wordpress.org/trunk@22331 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dion Hulse 2012-10-30 20:58:35 +00:00
parent 3417e0245a
commit a24d651e0e

View File

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