Skip to content

Commit

Permalink
Updated regexp in assets::buildCss() to fix issue where it matched …
Browse files Browse the repository at this point in the history
…a trailing quote, and streamlined how it handles inline data URI's.

Fixed bugs where `realpath()` cannot handle URL's with querystrings or hashbangs, it now just uses the path component.
Updated `config::__construct()` to handled the return value of `overview::draw()` as a string or null.
  • Loading branch information
hexydec committed Sep 20, 2021
1 parent 06b7d59 commit 18b846e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ public static function buildCss(array $files, string $target, ?array $minify = n
// get the CSS documents and rewrite the URL's
$css = '';
foreach ($files AS $item) {
if (($file = \file_get_contents($dir.$item)) !== false) {
$css .= \preg_replace_callback('/url\\([\'"]?+(?!data:)([^\\)]++)[\'"]?\\)/i', function (array $match) use ($item) {
if (($file = \file_get_contents($item)) !== false) {
$css .= \preg_replace_callback('/url\\([\'"]?+([^\\)"\':]++)[\'"]?\\)/i', function (array $match) use ($item) {
\chdir(\dirname($item));
$path = \realpath($match[1]);
$path = \realpath(\dirname($match[1])).'/'.\basename($match[1]);
return 'url('.\str_replace('\\', '/', \substr($path, \strlen($_SERVER['DOCUMENT_ROOT']))).')';
}, $file);
}
Expand Down
2 changes: 1 addition & 1 deletion config.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ class config extends packages {
public function __construct() {

// render the overview
$this->options['overview']['html'] = function () : string {
$this->options['overview']['html'] = function () : ?string {
$obj = new overview();
return $obj->draw();
};
Expand Down

0 comments on commit 18b846e

Please sign in to comment.