From 3defc7abde24120d344b52485375cb650096daca Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Mon, 25 Jan 2016 14:49:29 +0100 Subject: [PATCH] Fixed CSS url caching bug --- h5p-default-storage.class.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/h5p-default-storage.class.php b/h5p-default-storage.class.php index 2821b40..bc6f83e 100644 --- a/h5p-default-storage.class.php +++ b/h5p-default-storage.class.php @@ -176,10 +176,12 @@ class H5PDefaultStorage implements \H5PFileStorage { $content .= preg_replace_callback( '/url\([\'"]?([^"\')]+)[\'"]?\)/i', function ($matches) use ($cssRelPath) { - return substr($matches[1], 0, 3) !== '../' ? $matches[0] : 'url("../' . $cssRelPath . $matches[1] . '")'; + if (preg_match("/^([a-z0-9]+:)?\//i", $matches[1]) === 1) { + return $matches[0]; // Not relative, skip + } + return 'url("../' . $cssRelPath . $matches[1] . '")'; }, - $assetContent - ) . "\n"; + $assetContent) . "\n"; } }