diff --git a/min/lib/Minify/CSS/UriRewriter.php b/min/lib/Minify/CSS/UriRewriter.php index 8845f15..50360ce 100644 --- a/min/lib/Minify/CSS/UriRewriter.php +++ b/min/lib/Minify/CSS/UriRewriter.php @@ -282,11 +282,8 @@ class Minify_CSS_UriRewriter { ? $m[1] : substr($m[1], 1, strlen($m[1]) - 2); } - // analyze URI - if ('/' !== $uri[0] // root-relative - && false === strpos($uri, '//') // protocol (non-data) - && 0 !== strpos($uri, 'data:') // data protocol - ) { + // if not root/scheme relative and not starts with scheme + if (!preg_match('~^(/|[a-z]+\:)~', $uri)) { // URI is file-relative: rewrite depending on options if (self::$_prependPath === null) { $uri = self::rewriteRelative($uri, self::$_currentDir, self::$_docRoot, self::$_symlinks); diff --git a/min_unit_tests/_test_files/css_uriRewriter/exp.css b/min_unit_tests/_test_files/css_uriRewriter/exp.css index d749295..bd6d69e 100644 --- a/min_unit_tests/_test_files/css_uriRewriter/exp.css +++ b/min_unit_tests/_test_files/css_uriRewriter/exp.css @@ -3,12 +3,12 @@ @import '/_test_files/bar/foo.css' print; @import '/foo.css' print; @import '/css/foo.css'; /* abs, should not alter */ -@import 'http://foo.com/css/foo.css'; /* abs, should not alter */ +@import 'http://foo.com/css/foo.css'; /* scheme, should not alter */ @import url(/_test_files/foo.css) tv, projection; @import url("/css/foo.css"); /* abs, should not alter */ @import url(/css2/foo.css); /* abs, should not alter */ -@import url(data:image/gif;base64,AAAA); /* data, should not alter */ +@import url(foo:bar); /* scheme, should not alter */ foo {background:url('/_test_files/css_uriRewriter/bar/foo.png')} -foo {background:url('http://foo.com/css/foo.css');} /* abs, should not alter */ +foo {background:url('http://foo.com/css/foo.css');} /* scheme, should not alter */ foo {background:url("//foo.com/css/foo.css");} /* protocol relative, should not alter */ -foo {background:url(data:image/gif;base64,AAAA);} /* data, should not alter */ \ No newline at end of file +foo {background:url(foo:bar);} /* scheme, should not alter */ diff --git a/min_unit_tests/_test_files/css_uriRewriter/exp_prepend.css b/min_unit_tests/_test_files/css_uriRewriter/exp_prepend.css index 87b7ecb..d00cd35 100644 --- a/min_unit_tests/_test_files/css_uriRewriter/exp_prepend.css +++ b/min_unit_tests/_test_files/css_uriRewriter/exp_prepend.css @@ -3,12 +3,12 @@ @import 'http://cnd.com/A/bar/foo.css' print; @import 'http://cnd.com/foo.css' print; @import '/css/foo.css'; /* abs, should not alter */ -@import 'http://foo.com/css/foo.css'; /* abs, should not alter */ +@import 'http://foo.com/css/foo.css'; /* scheme, should not alter */ @import url(http://cnd.com/A/foo.css) tv, projection; @import url("/css/foo.css"); /* abs, should not alter */ @import url(/css2/foo.css); /* abs, should not alter */ -@import url(data:image/gif;base64,AAAA); /* data, should not alter */ +@import url(foo:bar); /* scheme, should not alter */ foo {background:url('http://cnd.com/A/B/bar/foo.png')} -foo {background:url('http://foo.com/css/foo.css');} /* abs, should not alter */ +foo {background:url('http://foo.com/css/foo.css');} /* scheme, should not alter */ foo {background:url("//foo.com/css/foo.css");} /* protocol relative, should not alter */ -foo {background:url(data:image/gif;base64,AAAA);} /* data, should not alter */ \ No newline at end of file +foo {background:url(foo:bar);} /* scheme, should not alter */ diff --git a/min_unit_tests/_test_files/css_uriRewriter/exp_prepend2.css b/min_unit_tests/_test_files/css_uriRewriter/exp_prepend2.css index ceea4ec..55badf5 100644 --- a/min_unit_tests/_test_files/css_uriRewriter/exp_prepend2.css +++ b/min_unit_tests/_test_files/css_uriRewriter/exp_prepend2.css @@ -3,12 +3,12 @@ @import '//cnd.com/A/bar/foo.css' print; @import '//cnd.com/foo.css' print; @import '/css/foo.css'; /* abs, should not alter */ -@import 'http://foo.com/css/foo.css'; /* abs, should not alter */ +@import 'http://foo.com/css/foo.css'; /* scheme, should not alter */ @import url(//cnd.com/A/foo.css) tv, projection; @import url("/css/foo.css"); /* abs, should not alter */ @import url(/css2/foo.css); /* abs, should not alter */ -@import url(data:image/gif;base64,AAAA); /* data, should not alter */ +@import url(foo:bar); /* scheme, should not alter */ foo {background:url('//cnd.com/A/B/bar/foo.png')} -foo {background:url('http://foo.com/css/foo.css');} /* abs, should not alter */ +foo {background:url('http://foo.com/css/foo.css');} /* scheme, should not alter */ foo {background:url("//foo.com/css/foo.css");} /* protocol relative, should not alter */ -foo {background:url(data:image/gif;base64,AAAA);} /* data, should not alter */ \ No newline at end of file +foo {background:url(foo:bar);} /* scheme, should not alter */ diff --git a/min_unit_tests/_test_files/css_uriRewriter/in.css b/min_unit_tests/_test_files/css_uriRewriter/in.css index aa41d0a..3497b87 100644 --- a/min_unit_tests/_test_files/css_uriRewriter/in.css +++ b/min_unit_tests/_test_files/css_uriRewriter/in.css @@ -3,12 +3,12 @@ @import '../bar/foo.css' print; @import '../../foo.css' print; @import '/css/foo.css'; /* abs, should not alter */ -@import 'http://foo.com/css/foo.css'; /* abs, should not alter */ +@import 'http://foo.com/css/foo.css'; /* scheme, should not alter */ @import url(../foo.css) tv, projection; @import url("/css/foo.css"); /* abs, should not alter */ @import url(/css2/foo.css); /* abs, should not alter */ -@import url(data:image/gif;base64,AAAA); /* data, should not alter */ +@import url(foo:bar); /* scheme, should not alter */ foo {background:url('bar/foo.png')} -foo {background:url('http://foo.com/css/foo.css');} /* abs, should not alter */ +foo {background:url('http://foo.com/css/foo.css');} /* scheme, should not alter */ foo {background:url("//foo.com/css/foo.css");} /* protocol relative, should not alter */ -foo {background:url(data:image/gif;base64,AAAA);} /* data, should not alter */ \ No newline at end of file +foo {background:url(foo:bar);} /* scheme, should not alter */