1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-19 12:21:20 +02:00

Makes sure all file/dir paths are normalized to prepare for comparing.

Particularly the system docRoot and currentDir values passed to the URI
rewriter and the allowDirs check.
This commit is contained in:
Steve Clay
2016-05-12 13:29:54 -04:00
parent 7aac6792bc
commit de39966e9c
6 changed files with 50 additions and 17 deletions

View File

@@ -110,20 +110,6 @@ class Minify_Source_Factory {
return $realpath;
}
/**
* turn windows-style slashes into unix-style,
* remove trailing slash
* and lowercase drive letter
*
* @param string $path absolute path
*
* @return string
*/
public function getNormalizedPath($path)
{
return lcfirst(rtrim(str_replace('\\', '/', $path), '/'));
}
/**
* @param mixed $spec
*
@@ -159,8 +145,9 @@ class Minify_Source_Factory {
if ($this->options['checkAllowDirs']) {
$allowDirs = (array)$this->options['allowDirs'];
$inAllowedDir = false;
$filePath = $this->env->normalizePath($spec['filepath']);
foreach ($allowDirs as $allowDir) {
if (strpos($this->getNormalizedPath($spec['filepath']), $this->getNormalizedPath($allowDir)) === 0) {
if (strpos($filePath, $this->env->normalizePath($allowDir)) === 0) {
$inAllowedDir = true;
}
}