mirror of
https://github.com/mrclay/minify.git
synced 2025-08-28 16:19:59 +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:
@@ -33,6 +33,7 @@ class Minify_Env {
|
||||
} else {
|
||||
$this->server['DOCUMENT_ROOT'] = rtrim($this->server['DOCUMENT_ROOT'], '/\\');
|
||||
}
|
||||
$this->server['DOCUMENT_ROOT'] = $this->normalizePath($this->server['DOCUMENT_ROOT']);
|
||||
$this->get = $options['get'];
|
||||
$this->post = $options['post'];
|
||||
$this->cookie = $options['cookie'];
|
||||
@@ -76,6 +77,29 @@ class Minify_Env {
|
||||
return isset($this->post[$key]) ? $this->post[$key] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* turn windows-style slashes into unix-style,
|
||||
* remove trailing slash
|
||||
* and lowercase drive letter
|
||||
*
|
||||
* @param string $path absolute path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function normalizePath($path)
|
||||
{
|
||||
$realpath = realpath($path);
|
||||
if ($realpath) {
|
||||
$path = $realpath;
|
||||
}
|
||||
$path = str_replace('\\', '/', $path);
|
||||
$path = rtrim($path, '/');
|
||||
if (substr($path, 1, 1) === ':') {
|
||||
$path = lcfirst($path);
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
protected $server = null;
|
||||
protected $get = null;
|
||||
protected $post = null;
|
||||
|
Reference in New Issue
Block a user