Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes #80 - quotation in multi line strings.

  • Loading branch information...
commit 8acc7a0be91ee0374c3fd8ddf23e4625fcf0f0cf 1 parent 4309611
Goal Smashers Dev Team GoalSmashers authored
1  History.md
View
@@ -6,6 +6,7 @@
* Fixed issue [#44](https://github.com/GoalSmashers/clean-css/issues/44) - examples in --help.
* Fixed issue [#83](https://github.com/GoalSmashers/clean-css/issues/83) - HSL to hex color conversions.
* Fixed issue [#2](https://github.com/GoalSmashers/clean-css/issues/2) - resolving @import rules.
+* Fixed issue [#80](https://github.com/GoalSmashers/clean-css/issues/80) - quotation in multi line strings.
0.10.2 / 2013-03-19
==================
15 lib/clean.js
View
@@ -74,6 +74,9 @@ var CleanCSS = {
};
}
+ // replace all escaped line breaks
+ replace(/\\(\r\n|\n)/mg, '');
+
// inline all imports
replace(function inlineImports() {
data = CleanCSS._inlineImports(data, {
@@ -88,11 +91,11 @@ var CleanCSS = {
});
// strip parentheses in urls if possible (no spaces inside)
- replace(/url\(['"]([^\)]+)['"]\)/g, function(urlMatch) {
- if (urlMatch.match(/\s/g) !== null)
- return urlMatch;
+ replace(/url\((['"])([^\)]+)['"]\)/g, function(match, quote, url) {
+ if (url.match(/[ \t]/g) !== null)
+ return 'url(' + quote + url + quote + ')';
else
- return urlMatch.replace(/\(['"]/, '(').replace(/['"]\)$/, ')');
+ return 'url(' + url + ')';
});
// strip parentheses in animation & font names
@@ -120,7 +123,7 @@ var CleanCSS = {
var key = content.substring(0, eqIndex);
var value = content.substring(eqIndex + 1, content.length);
- if (/^['"](?:[a-zA-Z][a-zA-Z\d\-]+)['"]$/.test(value))
+ if (/^['"](?:[a-zA-Z][a-zA-Z\d\-_]+)['"]$/.test(value))
return '[' + key + '=' + value.substring(1, value.length - 1) + ']';
else
return match;
@@ -327,7 +330,7 @@ var CleanCSS = {
});
replace(/__CSSFREETEXT__/g, function() {
- return context.freeTextBlocks.shift().replace(/\\(\r\n|\n)/mg, '');
+ return context.freeTextBlocks.shift();
});
var specialCommentsCount = context.specialComments.length;
2  test/data/big-min.css
View
@@ -1002,7 +1002,7 @@ label i{display:none;font-style:normal;display:none}
.liste_reactions .bulle span{display:block;-webkit-box-shadow:0 3px 2px 1px rgba(0,11,21,.2);-moz-box-shadow:0 3px 2px 1px rgba(0,11,21,.2);box-shadow:0 3px 2px 1px rgba(0,11,21,.2);border-radius:4px;padding:10px;background:#fff}
.liste_reactions .references{font-weight:700}
.liste_reactions .references .date{color:#8b9299}
-.liste_reactions input[class=btn],.liste_reactions input[class="btn_abo"]{margin:5px 0 10px}
+.liste_reactions input[class=btn],.liste_reactions input[class=btn_abo]{margin:5px 0 10px}
.reaction_identifier,.reaction_redaction{margin:20px 0;background:#f5f8f9;border-top:3px solid #e9ecf0}
.reaction_redaction{padding:0 0 10px}
.reaction_identifier .deja_abo{float:left;width:275px;border-left:1px solid #ebeff0}
3  test/data/line-breaks-in-attributes-min.css
View
@@ -1 +1,2 @@
-.test[title="my very long title"]{background-image:url("very/long/path")}
+.test[title="my very long title"]{background-image:url(very/long/path)}
+.test[title=my_very_long_title]{background-image:url(my/very/long/path)}
7 test/data/line-breaks-in-attributes.css
View
@@ -1,3 +1,8 @@
.test[title="my very long \
title"]{background-image:url("very/long/\
-path")}
+path")}
+.test[title="my_very_long_\
+title"] {
+ background-image: url("my/very/long/\
+path")
+}
12 test/unit-test.js
View
@@ -565,6 +565,11 @@ vows.describe('clean-units').addBatch({
'a{background:url(/very/long/\
path)}',
'a{background:url(/very/long/path)}'
+ ],
+ 'strip new line in urls which could be unquoted': [
+ 'a{background:url("/very/long/\
+path")}',
+ 'a{background:url(/very/long/path)}'
]
}),
'fonts': cssContext({
@@ -625,7 +630,7 @@ path)}',
'should keep selector if no quotation': 'div[data-type=something]{border-color:red}',
'should keep selector if equals in value': 'div[data-type="stupid=value"]{border-color:red}',
'should keep quotation if whitespace inside': 'div[data-type^=\'object 1\']{border-color:red}',
- 'should keep quotations if special characters inside': 'a[data-type="object_1"]{color:red}a[data-target="#some-place"]{color:red}',
+ 'should keep quotations if special characters inside': 'a[data-type="object+1"]{color:red}a[data-target="#some-place"]{color:red}',
'should keep quotation if is a number': 'div[data-number=\'1\']{border-color:red}',
'should keep quotation if starts with a number': 'div[data-type^=\'1something\']{border-color:red}',
'should keep quotation if starts with a hyphen': 'div[data-type$=\'-something\']{border-color:red}',
@@ -647,6 +652,11 @@ path)}',
".test[title='my very long \
title']",
".test[title='my very long title']"
+ ],
+ 'should strip new lines inside attributes which can be unquoted': [
+ ".test[title='my_very_long_\
+title']",
+ ".test[title=my_very_long_title]"
]
}),
'ie filters': cssContext({
Please sign in to comment.
Something went wrong with that request. Please try again.