From d3161a06a1abcf20efb143ee7139cbf0b66d4cf3 Mon Sep 17 00:00:00 2001 From: Maxim Zemskov Date: Sat, 18 Aug 2012 18:24:30 +0600 Subject: [PATCH] Fixed bugs in rewriteUrls(). (#119) --- lessc.inc.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lessc.inc.php b/lessc.inc.php index b699bccf..343af55e 100644 --- a/lessc.inc.php +++ b/lessc.inc.php @@ -747,13 +747,14 @@ protected function compileValue($value, $inUrl = false) { list(, $delim, $content) = $value; foreach ($content as &$part) { if (is_array($part)) { - $part = $this->compileValue($part, $inUrl); - } - if ($inUrl && $this->allowUrlRewrite) { - $part = $this->rewriteUrls($part); + $part = $this->compileValue($part, false); } } - return $delim . implode($content) . $delim; + $content = implode($content); + if ($inUrl && $this->allowUrlRewrite) { + $content = $this->rewriteUrls($content); + } + return $delim . $content . $delim; case 'color': // [1] - red component (either number or a %) // [2] - green component @@ -794,6 +795,9 @@ protected function rewriteUrls($url) { $baseImportDir = realpath(end($this->importDir)); $lastImportDir = realpath(reset($this->importDir)); + if ($baseImportDir === $lastImportDir) + return $url; + $urlPath = realpath($lastImportDir.DIRECTORY_SEPARATOR.$url); if ($urlPath === false) return $url; @@ -803,7 +807,7 @@ protected function rewriteUrls($url) { $i = 0; foreach ($baseArray as $i => $segment) { - if ($baseArray[$i] !== $urlArray[$i]) + if (!isset($baseArray[$i], $urlArray[$i]) || $baseArray[$i] !== $urlArray[$i]) break; }