From f247808cb61d21255b9463c8f28d8aa55cf5e774 Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Mon, 24 Jun 2024 15:52:18 +0000 Subject: [PATCH] Editor: Fix Path Traversal issue on Windows in Template-Part Block. Merges [58470] to the 4.2 branch. Props xknown, jorbin. git-svn-id: https://develop.svn.wordpress.org/branches/4.2@58500 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index f4f8a44a312b9..8b0976369b2a9 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -3781,6 +3781,9 @@ function iis7_supports_permalinks() { * @return int 0 means nothing is wrong, greater than 0 means something was wrong. */ function validate_file( $file, $allowed_files = '' ) { + // Normalize path for Windows servers + $file = wp_normalize_path( $file ); + if ( false !== strpos( $file, '..' ) ) return 1;