From 340c8a91fe993b0f908a0327682a5af873f65321 Mon Sep 17 00:00:00 2001 From: Steve Clay Date: Wed, 8 Oct 2008 13:20:12 +0000 Subject: [PATCH] Issue 24. Make sure all accesses of DOCUMENT_ROOT are first passed through realpath() to resolve symlinks. --- min/lib/Minify/CSS.php | 10 ++++------ min/lib/Minify/ImportProcessor.php | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/min/lib/Minify/CSS.php b/min/lib/Minify/CSS.php index 7fa6f26..5440471 100644 --- a/min/lib/Minify/CSS.php +++ b/min/lib/Minify/CSS.php @@ -282,7 +282,7 @@ class Minify_CSS { $path = self::$_tempCurrentDir . DIRECTORY_SEPARATOR . strtr($url, '/', DIRECTORY_SEPARATOR); // strip doc root - $path = substr($path, strlen($_SERVER['DOCUMENT_ROOT'])); + $path = substr($path, strlen(realpath($_SERVER['DOCUMENT_ROOT']))); // fix to absolute URL $url = strtr($path, DIRECTORY_SEPARATOR, '/'); // remove /./ and /../ where possible @@ -294,11 +294,9 @@ class Minify_CSS { } } } - if ($isImport) { - return "@import {$quote}{$url}{$quote}"; - } else { - return "url({$quote}{$url}{$quote})"; - } + return $isImport + ? "@import {$quote}{$url}{$quote}" + : "url({$quote}{$url}{$quote})"; } /** diff --git a/min/lib/Minify/ImportProcessor.php b/min/lib/Minify/ImportProcessor.php index b03fef8..be7efb7 100644 --- a/min/lib/Minify/ImportProcessor.php +++ b/min/lib/Minify/ImportProcessor.php @@ -141,7 +141,7 @@ class Minify_ImportProcessor { $path = $this->_currentDir . DIRECTORY_SEPARATOR . strtr($url, '/', DIRECTORY_SEPARATOR); // strip doc root - $path = substr($path, strlen($_SERVER['DOCUMENT_ROOT'])); + $path = substr($path, strlen(realpath($_SERVER['DOCUMENT_ROOT']))); // fix to absolute URL $url = strtr($path, DIRECTORY_SEPARATOR, '/'); // remove /./ and /../ where possible