* Unifies wrappers for simple & advanced optimizations.
* Fixed issue [#599](https://github.com/jakubpawlowicz/clean-css/issues/599) - support for inlined source maps.
+[3.3.9 / 2015-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.8...3.3)
+==================
+
+* Fixed issue [#640](https://github.com/jakubpawlowicz/clean-css/issues/640) - URI processing regression.
+
[3.3.8 / 2015-08-06](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.7...v3.3.8)
==================
var URL_PREFIX = 'url(';
var UPPERCASE_URL_PREFIX = 'URL(';
var URL_SUFFIX = ')';
+var DATA_URI_PREFIX = 'data:';
var IMPORT_URL_PREFIX = '@import';
var UPPERCASE_IMPORT_URL_PREFIX = '@IMPORT';
var nextStartUpperCase = 0;
var nextEnd = 0;
var nextEndAhead = 0;
+ var isDataURI = false;
var cursor = 0;
var tempData = [];
var hasUppercaseUrl = data.indexOf(UPPERCASE_URL_PREFIX) > -1;
if (nextStart == -1 && nextStartUpperCase > -1)
nextStart = nextStartUpperCase;
+
if (data[nextStart + URL_PREFIX.length] == '"') {
nextEnd = data.indexOf('"', nextStart + URL_PREFIX.length + 1);
} else if (data[nextStart + URL_PREFIX.length] == '\'') {
nextEnd = data.indexOf('\'', nextStart + URL_PREFIX.length + 1);
} else {
+ isDataURI = data.substring(nextStart + URL_PREFIX.length).trim().indexOf(DATA_URI_PREFIX) === 0;
nextEnd = data.indexOf(URL_SUFFIX, nextStart);
- while (true) {
- nextEndAhead = data.indexOf(URL_SUFFIX, nextEnd + 1);
- // if it has whitespace then we should be out of URL, otherwise keep iterating
- // if it has not but content is not escaped, it has to be quoted so it will be captured
- // by either of two clauses above
- if (nextEndAhead == -1 || /\s/.test(data.substring(nextEnd, nextEndAhead)))
- break;
-
- nextEnd = nextEndAhead;
+ if (isDataURI) {
+ // this is a fuzzy matching logic for unqoted data URIs
+ while (true) {
+ nextEndAhead = data.indexOf(URL_SUFFIX, nextEnd + 1);
+ // if it has whitespace then we should be out of URL, otherwise keep iterating
+ // if it has not but content is not escaped, it has to be quoted so it will be captured
+ // by either of two clauses above
+ if (nextEndAhead == -1 || /\s/.test(data.substring(nextEnd, nextEndAhead)))
+ break;
+
+ nextEnd = nextEndAhead;
+ }
}
}
'div{background:url("some/).png") repeat}',
'div{background:__ESCAPED_URL_CLEAN_CSS0__ repeat}',
'div{background:url("some/).png") repeat}'
+ ],
+ 'followed by attribute matcher selector': [
+ 'a{background:url(url)}div:not([test]){color:red}',
+ 'a{background:__ESCAPED_URL_CLEAN_CSS0__}div:not([test]){color:red}',
+ 'a{background:url(url)}div:not([test]){color:red}'
]
})
)