From: GoalSmashers Date: Fri, 3 Jan 2014 14:58:38 +0000 (+0100) Subject: Fixes #205 - freeze on broken @import declaration. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=99f85a118083e466f18dfc993bc46cf926b5e814;p=clean-css.git Fixes #205 - freeze on broken @import declaration. @import declarations without trailing semicolon led to an infinite loop in tokenizer. --- diff --git a/History.md b/History.md index ba63b4f1..d46fa502 100644 --- a/History.md +++ b/History.md @@ -9,6 +9,11 @@ * Fixed issue [#165](https://github.com/GoalSmashers/clean-css/issues/165) - extra space after trailing parenthesis. * Fixed issue [#186](https://github.com/GoalSmashers/clean-css/issues/186) - strip unit from 0rem. +[2.0.6 / 2014-xx-xx (UNRELEASED)](https://github.com/GoalSmashers/clean-css/compare/v2.0.5...v2.0.6) +================== + +* Fixed issue [#205](https://github.com/GoalSmashers/clean-css/issues/205) - freeze on broken @import declaration. + [2.0.5 / 2014-01-03](https://github.com/GoalSmashers/clean-css/compare/v2.0.4...v2.0.5) ================== diff --git a/lib/imports/inliner.js b/lib/imports/inliner.js index e1e359a3..f67ad59f 100644 --- a/lib/imports/inliner.js +++ b/lib/imports/inliner.js @@ -26,8 +26,11 @@ module.exports = function Inliner(context) { } nextEnd = data.indexOf(';', nextStart); - if (nextEnd == -1) + if (nextEnd == -1) { + tempData.push(''); + cursor = data.length; break; + } tempData.push(data.substring(cursor, nextStart)); tempData.push(inlinedFile(data, nextStart, nextEnd, options)); diff --git a/test/unit-test.js b/test/unit-test.js index a31ae7b4..66d18f15 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -1011,6 +1011,10 @@ title']{display:block}", "@import url('fake.css');", '' ], + 'of an unknown file with a missing trailing semicolon': [ + "@import url(fake.css)", + '' + ], 'of a http file': "@import url(http://pro.goalsmashers.com/test.css);", 'of a https file': [ "@import url('https://pro.goalsmashers.com/test.css');", @@ -1070,6 +1074,14 @@ title']{display:block}", '@import \'test/data/partials/one.css\' screen and (orientation:landscape);', "@media screen and (orientation:landscape){.one{color:red}}" ], + 'of a real file with a missing trailing semicolon': [ + "@import url(test/data/partials/one.css)", + '' + ], + 'of a real files with a missing trailing semicolon': [ + "@import url(test/data/partials/one.css)@import url(test/data/partials/two.css)", + '' + ], 'of more files': [ "@import url(test/data/partials/one.css);\n\na{display:block}\n\n@import url(test/data/partials/extra/three.css);", ".one{color:red}a{display:block}.three{color:#0f0}"