* Fixed issue [#344](https://github.com/GoalSmashers/clean-css/issues/344) - merging background-size into shorthand.
* Fixed issue [#360](https://github.com/GoalSmashers/clean-css/issues/360) - adds 7 extra CSS colors.
* Fixed issue [#363](https://github.com/GoalSmashers/clean-css/issues/363) - `rem` units overriding `px`.
+* Fixed issue [#395](https://github.com/GoalSmashers/clean-css/issues/395) - unescaped brackets in data URIs.
[2.2.19 / 2014-11-20](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.18...v2.2.19)
==================
var EscapeStore = require('./escape-store');
+var URL_PREFIX = 'url(';
+var URL_SUFFIX = ')';
+
var UrlsProcessor = function UrlsProcessor(context) {
this.urls = new EscapeStore('URL');
this.context = context;
var tempData = [];
for (; nextEnd < data.length;) {
- nextStart = data.indexOf('url(', nextEnd);
+ nextStart = data.indexOf(URL_PREFIX, nextEnd);
if (nextStart == -1)
break;
- nextEnd = data.indexOf(')', nextStart);
+ 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
+ nextEnd = data.indexOf(URL_SUFFIX, nextStart);
+
// Following lines are a safety mechanism to ensure
// incorrectly terminated urls are processed correctly.
if (nextEnd == -1) {
nextEnd--;
this.context.warnings.push('Broken URL declaration: \'' + data.substring(nextStart, nextEnd + 1) + '\'.');
+ } else {
+ if (data[nextEnd] != URL_SUFFIX)
+ nextEnd = data.indexOf(URL_SUFFIX, nextEnd);
}
var url = data.substring(nextStart, nextEnd + 1);
.replace(/^url\((['"])? /, 'url($1')
.replace(/ (['"])?\)$/, '$1)');
- if (url.indexOf(' ') == -1 && !/url\(['"]data:[^;]+;charset/.test(url))
+ if (!/url\(.*[\s\(\)].*\)/.test(url) && !/url\(['"]data:[^;]+;charset/.test(url))
url = url.replace(/["']/g, '');
return url;
'div{background:url(\' some/\nfile.png \') repeat}',
'div{background:__ESCAPED_URL_CLEAN_CSS0__ repeat}',
'div{background:url(some/file.png) repeat}'
+ ],
+ 'unescaped closing brackets': [
+ 'div{background:url("some/).png") repeat}',
+ 'div{background:__ESCAPED_URL_CLEAN_CSS0__ repeat}',
+ 'div{background:url("some/).png") repeat}'
]
})
)