From 2722345aac680cce0025bd7a70c5a5a86b987d49 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 30 Mar 2018 10:45:35 -0400 Subject: [PATCH] Attempt to fix issue processwire/processwire-issues#554 isue with $files->include() and Windows paths --- wire/core/WireFileTools.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wire/core/WireFileTools.php b/wire/core/WireFileTools.php index bc9906d8..4f363fcb 100644 --- a/wire/core/WireFileTools.php +++ b/wire/core/WireFileTools.php @@ -693,7 +693,6 @@ class WireFileTools extends Wire { $options = array_merge($defaults, $options); $filename = trim($filename); - if(DIRECTORY_SEPARATOR != '/') $filename = str_replace(DIRECTORY_SEPARATOR, '/', $filename); // add .php extension if filename doesn't already have an extension if($options['autoExtension'] && !strrpos(basename($filename), '.')) { @@ -706,6 +705,8 @@ class WireFileTools extends Wire { $filename = realpath($filename); if($filename === false) throw new WireException("File does not exist: $_filename"); } + + if(DIRECTORY_SEPARATOR != '/') $filename = str_replace(DIRECTORY_SEPARATOR, '/', $filename); if(strpos($filename, '//') !== false) { throw new WireException("File is not allowed (double-slash): $filename"); @@ -722,6 +723,7 @@ class WireFileTools extends Wire { // absolute path, make sure it's part of PW's installation $allowed = false; foreach($options['allowedPaths'] as $path) { + if(DIRECTORY_SEPARATOR != '/') $path = str_replace(DIRECTORY_SEPARATOR, '/', $path); if(strpos($filename, $path) === 0) $allowed = true; } if(!$allowed) throw new WireException("File is not in an allowed path: $filename");