From 6ff4695bbb8415139b08595985d94e58d343011e Mon Sep 17 00:00:00 2001 From: Jakub Pawlowicz Date: Sat, 4 Feb 2017 07:17:00 +0100 Subject: [PATCH] Fixes #879 - incorrect handling of spaces in paths. Why: * When reading sources passed in as array, paths need to be wrapped in `url()` so spaces are handled correctly. --- History.md | 1 + lib/reader/read-sources.js | 2 +- test/fixtures/partials/with spaces in filename.css | 3 +++ test/module-test.js | 8 ++++++++ 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/partials/with spaces in filename.css diff --git a/History.md b/History.md index f51c8572..326057c0 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ [4.0.4 / 2017-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v4.0.3...4.0) ================== +* Fixed issue [#879](https://github.com/jakubpawlowicz/clean-css/issues/879) - incorrect handling of spaces in paths. * Fixed issue [#878](https://github.com/jakubpawlowicz/clean-css/issues/878) - invalid double backslash tokenization. [4.0.3 / 2017-01-30](https://github.com/jakubpawlowicz/clean-css/compare/v4.0.2...v4.0.3) diff --git a/lib/reader/read-sources.js b/lib/reader/read-sources.js index 653c8fb0..3e10baa3 100644 --- a/lib/reader/read-sources.js +++ b/lib/reader/read-sources.js @@ -116,7 +116,7 @@ function trackSourceMap(sourceMap, uri, context) { } function restoreAsImport(uri) { - return restoreImport(uri, '') + Marker.SEMICOLON; + return restoreImport('url(' + uri + ')', '') + Marker.SEMICOLON; } function fromStyles(styles, context, parentInlinerContext, callback) { diff --git a/test/fixtures/partials/with spaces in filename.css b/test/fixtures/partials/with spaces in filename.css new file mode 100644 index 00000000..26e73872 --- /dev/null +++ b/test/fixtures/partials/with spaces in filename.css @@ -0,0 +1,3 @@ +.block { + color:#f00; +} diff --git a/test/module-test.js b/test/module-test.js index a7e856ce..9b31cebc 100644 --- a/test/module-test.js +++ b/test/module-test.js @@ -571,6 +571,14 @@ vows.describe('module tests').addBatch({ assert.equal(minified.styles, '.one{color:red}.three{color:#0f0}.four{color:#00f}.two{color:#fff}.base2{border-width:0}.sub{padding:0}.base{margin:0}'); } } + }, + 'with spaces in filename': { + 'topic': function () { + return new CleanCSS().minify(['./test/fixtures/partials/with spaces in filename.css']); + }, + 'gives right output': function (minified) { + assert.equal(minified.styles, '.block{color:red}'); + } } }, 'accepts a list of source files as hash': { -- 2.34.1