Filesystem: Normalize allowed_files so comparison is apples to apples.

In [58470] a change was made to normalize the filename in validate_file, however this leads to instances where the list of files that are allowed aren't normalized such as in the theme editor. By normalizing the array, the comparison is apples to apples.

Reviewed by hellofromTonya.
Merges 58570 to the 6.5 branch.

Fixes #61488.
Props jorbin, hellofromtonya, swissspidy, misulicus, script2see, Presskopp, audrasjb, peterwilsoncc, siliconforks, littler.chicken, paulkevan,

Built from https://develop.svn.wordpress.org/branches/6.5@58808


git-svn-id: http://core.svn.wordpress.org/branches/6.5@58204 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Aaron Jorbin 2024-07-25 16:35:13 +00:00
parent 369fded277
commit 8911189d5a
2 changed files with 4 additions and 2 deletions

View File

@ -6192,8 +6192,10 @@ function validate_file( $file, $allowed_files = array() ) {
return 0;
}
// Normalize path for Windows servers
// Normalize path for Windows servers.
$file = wp_normalize_path( $file );
// Normalize path for $allowed_files as well so it's an apples to apples comparison.
$allowed_files = array_map( 'wp_normalize_path', $allowed_files );
// `../` on its own is not allowed:
if ( '../' === $file ) {

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.5.6-alpha-58658';
$wp_version = '6.5.6-alpha-58808';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.