From: GoalSmashers Date: Sat, 2 Nov 2013 09:07:04 +0000 (+0100) Subject: Fixes #159 - escaped quotes inside content property. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=8b225f40b80be04ef363dcc42265bd10c5a403c4;p=clean-css.git Fixes #159 - escaped quotes inside content property. --- diff --git a/History.md b/History.md index 069b41ab..e1a36964 100644 --- a/History.md +++ b/History.md @@ -6,6 +6,7 @@ * Adds simplified and much faster empty elements removal. * Adds missing `@import` processing to our benchmark (run via `npm run bench`). * Fixed issue [#157](https://github.com/GoalSmashers/clean-css/issues/157) - gets rid of `removeEmpty` option. +* Fixed issue [#159](https://github.com/GoalSmashers/clean-css/issues/159) - escaped quotes inside content. 1.1.7 / 2013-10-28 ================== diff --git a/lib/text/free.js b/lib/text/free.js index dab22b13..c66c4030 100644 --- a/lib/text/free.js +++ b/lib/text/free.js @@ -3,6 +3,22 @@ var EscapeStore = require('./escape-store'); module.exports = function Free() { var texts = new EscapeStore('CSSFREETEXT'); + var findNonEscapedEnd = function(data, matched, start) { + var end = start; + while (true) { + end = data.indexOf(matched, end); + + if (end > -1 && data[end - 1] == '\\') { + end += 1; + continue; + } else { + break; + } + } + + return end; + }; + return { // Strip content tags by replacing them by the __CSSFREETEXT__ // marker for further restoring. It's done via string scanning @@ -37,8 +53,8 @@ module.exports = function Free() { if (nextStart == -1) break; - nextEnd = data.indexOf(matchedParenthesis, nextStart + 1); - if (nextStart == -1 || nextEnd == -1) + nextEnd = findNonEscapedEnd(data, matchedParenthesis, nextStart + 1); + if (nextEnd == -1) break; var text = data.substring(nextStart, nextEnd + 1); diff --git a/test/data/issue-159-snippet-min.css b/test/data/issue-159-snippet-min.css new file mode 100644 index 00000000..3c24142e --- /dev/null +++ b/test/data/issue-159-snippet-min.css @@ -0,0 +1,7 @@ +.zocial.acrobat:before{content:"\00E3";color:#FB0000} +.zocial.amazon:before{content:"a"} +.zocial.android:before{content:"&"} +.zocial.angellist:before{content:"\00D6"} +.zocial.aol:before{content:"\""} +.zocial.appnet:before{content:"\00E1"} +.zocial.appstore:before{content:"A"} diff --git a/test/data/issue-159-snippet.css b/test/data/issue-159-snippet.css new file mode 100644 index 00000000..7c64f051 --- /dev/null +++ b/test/data/issue-159-snippet.css @@ -0,0 +1,7 @@ +.zocial.acrobat:before {content: "\00E3"; color: #FB0000;} +.zocial.amazon:before {content: "a";} +.zocial.android:before {content: "&";} +.zocial.angellist:before {content: "\00D6";} +.zocial.aol:before {content: "\"";} +.zocial.appnet:before {content: "\00E1";} +.zocial.appstore:before {content: "A";}