Permalink
Browse files

Stripping line breaks in attributes & urls. Follow up to #46.

  • Loading branch information...
1 parent 59d887d commit 30ed70f1ddb91eec5e357a7f3815cf3802039648 @GoalSmashers GoalSmashers committed Mar 16, 2013
Showing with 18 additions and 4 deletions.
  1. +1 −0 .jshintrc
  2. +1 −1 lib/clean.js
  3. +1 −0 test/data/line-breaks-in-attributes-min.css
  4. +3 −0 test/data/line-breaks-in-attributes.css
  5. +12 −3 test/unit-test.js
View
1 .jshintrc
@@ -7,6 +7,7 @@
"curly": false,
"eqeqeq": false,
"latedef": true,
+ "multistr": true,
"noarg": true,
"plusplus": false,
"regexp": false,
View
2 lib/clean.js
@@ -301,7 +301,7 @@ var CleanCSS = {
});
replace(/__CSSFREETEXT__/g, function() {
- return context.freeTextBlocks.shift();
+ return context.freeTextBlocks.shift().replace(/\\(\r\n|\n)/mg, '');
});
var specialCommentsCount = context.specialComments.length;
View
1 test/data/line-breaks-in-attributes-min.css
@@ -0,0 +1 @@
+.test[title="my very longtitle"]{background-image:url("very/long/path")}
View
3 test/data/line-breaks-in-attributes.css
@@ -0,0 +1,3 @@
+.test[title="my very long\
+title"]{background-image:url("very/long/\
+path")}
View
15 test/unit-test.js
@@ -532,7 +532,12 @@ vows.describe('clean-units').addBatch({
'keep urls from being stripped down #1': 'a{background:url(/image-1.0.png)}',
'keep urls from being stripped down #2': "a{background:url(/image-white.png)}",
'keep urls from being stripped down #3': "a{background:#eee url(libraries/jquery-ui-1.10.1.custom/images/ui-bg_highlight-soft_100_eeeeee_1x100.png) 50% top repeat-x}",
- 'keep __URL__ in comments (so order is important)': '/*! __URL__ */a{}'
+ 'keep __URL__ in comments (so order is important)': '/*! __URL__ */a{}',
+ 'strip new line in urls': [
+ 'a{background:url(/very/long/\
+path)}',
+ 'a{background:url(/very/long/path)}'
+ ]
}),
'fonts': cssContext({
'keep format quotation': "@font-face{font-family:PublicVintage;src:url(./PublicVintage.otf) format('opentype')}",
@@ -609,8 +614,12 @@ vows.describe('clean-units').addBatch({
'a[data-href*=object1]{border-color:red}a[data-href|=object2]{border-color:#0f0}'
],
'should keep special characters inside attributes #1': "a[data-css='color:white']",
- 'should keep special characters inside attributes #2': "a[data-text='a\nb\nc']",
- 'should keep special characters inside attributes #3': 'a[href="/version-0.01.html"]'
+ 'should keep special characters inside attributes #2': 'a[href="/version-0.01.html"]',
+ 'should strip new lines inside attributes': [
+ ".test[title='my very long\
+title']",
+ ".test[title='my very longtitle']"
+ ]
}),
'ie filters': cssContext({
'short alpha': [

0 comments on commit 30ed70f

Please sign in to comment.