From 5c40337ff0b7fbd8baa08a1dc8fdd0c7126fa0e7 Mon Sep 17 00:00:00 2001 From: Hugh Barnes Date: Mon, 27 Mar 2017 13:50:22 +1300 Subject: [PATCH] CSS pipeline rewrite URL fix for webserver root-based paths (#1383) * Implement fix to not rewrite paths in CSS pipeline when CSS URLs use a path startng at webserver root (e.g. url('/path/to/asset')) - fixes #1382 * Amend CSS pipeline's resource location checking predicates to use Utils::startsWith, and consolidate into a single predicate * Add back colon to data URL prefix test Copy error in last commit would have broken any relative path beginning with the string 'data' --- system/src/Grav/Common/Assets.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php index eeb3adabf..20b1fce26 100644 --- a/system/src/Grav/Common/Assets.php +++ b/system/src/Grav/Common/Assets.php @@ -1255,13 +1255,8 @@ class Assets $old_url = $matches[2]; - // ensure this is not a data url - if (strpos($old_url, 'data:') === 0) { - return $matches[0]; - } - - // ensure this is not a remote url - if ($this->isRemoteLink($old_url)) { + // Ensure link is not rooted to webserver, a data URL, or to a remote host + if (Utils::startsWith($old_url, '/') || Utils::startsWith($old_url, 'data:') || $this->isRemoteLink($old_url)) { return $matches[0]; }