Media: Fix deletion of files on Windows.
`wp_delete_file_from_directory()` should always normalize file paths before comparing. Props tonybogdanov, SergeyBiryukov. Fixes #47185. git-svn-id: https://develop.svn.wordpress.org/trunk@45352 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
3f641505fe
commit
76755c0e68
@ -6282,13 +6282,21 @@ function wp_delete_file( $file ) {
|
|||||||
*/
|
*/
|
||||||
function wp_delete_file_from_directory( $file, $directory ) {
|
function wp_delete_file_from_directory( $file, $directory ) {
|
||||||
if ( wp_is_stream( $file ) ) {
|
if ( wp_is_stream( $file ) ) {
|
||||||
$real_file = wp_normalize_path( $file );
|
$real_file = $file;
|
||||||
$real_directory = wp_normalize_path( $directory );
|
$real_directory = $directory;
|
||||||
} else {
|
} else {
|
||||||
$real_file = realpath( wp_normalize_path( $file ) );
|
$real_file = realpath( wp_normalize_path( $file ) );
|
||||||
$real_directory = realpath( wp_normalize_path( $directory ) );
|
$real_directory = realpath( wp_normalize_path( $directory ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( false !== $real_file ) {
|
||||||
|
$real_file = wp_normalize_path( $real_file );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( false !== $real_directory ) {
|
||||||
|
$real_directory = wp_normalize_path( $real_directory );
|
||||||
|
}
|
||||||
|
|
||||||
if ( false === $real_file || false === $real_directory || strpos( $real_file, trailingslashit( $real_directory ) ) !== 0 ) {
|
if ( false === $real_file || false === $real_directory || strpos( $real_file, trailingslashit( $real_directory ) ) !== 0 ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user