Skip to content

Commit

Permalink
Fixed bugs in rewriteUrls(). (leafo#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nodge committed Aug 18, 2012
1 parent 020d220 commit d3161a0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lessc.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down

0 comments on commit d3161a0

Please sign in to comment.