From 6e0ba7864fb5e012166530e2ab00b26f9ed81655 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Mon, 27 Nov 2017 03:27:19 +0000 Subject: [PATCH] Theme Editor: Validate files are editable based on their relative filenames, rather than full file path. This fixes theme editing on Windows platforms where `validate_file()` will return `2` on a full file path. Fixes #42609. git-svn-id: https://develop.svn.wordpress.org/trunk@42244 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/file.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php index ccd1a2e240..4144a79e33 100644 --- a/src/wp-admin/includes/file.php +++ b/src/wp-admin/includes/file.php @@ -445,7 +445,8 @@ function wp_edit_theme_plugin_file( $args ) { } } - if ( 0 !== validate_file( $real_file, $allowed_files ) ) { + // Compare based on relative paths + if ( 0 !== validate_file( $file, array_keys( $allowed_files ) ) ) { return new WP_Error( 'disallowed_theme_file', __( 'Sorry, that file cannot be edited.' ) ); }