==================
* Improves QuoteScanner to handle comments correctly.
+* Fixed issue [#308](https://github.com/GoalSmashers/clean-css/issues/308) - parsing comments in quoted urls.
* Fixed issue [#311](https://github.com/GoalSmashers/clean-css/issues/311) - leading/trailing decimal points.
[2.2.5 / 2014-06-29](https://github.com/GoalSmashers/clean-css/compare/v2.2.4...v2.2.5)
break;
tempData.push(data.substring(cursor, nextStart));
- var url = data.substring(nextStart + 4, nextEnd).replace(/['"]/g, '');
+ var url = data.substring(nextStart + 4, nextEnd);
+ if (!/\/\*|\*\//.test(url))
+ url = url.replace(/['"]/g, '');
+
tempData.push('url(' + this._rebased(url, options) + ')');
cursor = nextEnd + 1;
}
var EscapeStore = require('./escape-store');
+var QuoteScanner = require('./quote-scanner');
module.exports = function Comments(keepSpecialComments, keepBreaks, lineBreak) {
var comments = new EscapeStore('COMMENT');
var nextStart = 0;
var nextEnd = 0;
var cursor = 0;
+ var isQuotedAt = (function () {
+ var quoteMap = [];
+ new QuoteScanner(data).each(function (quotedString, _, startsAt) {
+ quoteMap.push([startsAt, startsAt + quotedString.length]);
+ });
+
+ return function (position) {
+ for (var i = 0, l = quoteMap.length; i < l; i++) {
+ if (quoteMap[i][0] < position && quoteMap[i][1] > position)
+ return true;
+ }
+
+ return false;
+ };
+ })();
for (; nextEnd < data.length;) {
nextStart = data.indexOf('/*', cursor);
+ if (nextStart == -1)
+ break;
+ if (isQuotedAt(nextStart)) {
+ tempData.push(data.substring(cursor, nextStart + 2));
+ cursor = nextStart + 2;
+ continue;
+ }
+
nextEnd = data.indexOf('*/', nextStart + 2);
- if (nextStart == -1 || nextEnd == -1)
+ if (nextEnd == -1)
break;
tempData.push(data.substring(cursor, nextStart));
--- /dev/null
+p{background-image:url(/*)}
--- /dev/null
+p {
+ background-image: url('/*');
+}
+
+/* */
'selector between comments': [
'/*comment*/*/*comment*/{color:red}',
'*{color:red}'
+ ],
+ 'inside url': [
+ "p{background-image:url('/*')}/* */",
+ "p{background-image:url(/*)}"
+ ],
+ 'inside url twice': [
+ "p{background-image:url('/* */\" /*')}/* */",
+ "p{background-image:url('/* */\" /*')}"
+ ],
+ 'inside url with more quotation': [
+ "p{background-image:url('/*');content:\"\"/* */}",
+ "p{background-image:url(/*);content:\"\"}"
+ ],
+ 'with quote marks': [
+ '/*"*//* */',
+ ''
]
}),
'escaping': cssContext({