From b0931cc53b6cd4b4127964156258db9fcbbf2d59 Mon Sep 17 00:00:00 2001 From: Joey Marianer Date: Sat, 26 Nov 2016 16:39:18 -0800 Subject: [PATCH] Fix parsing of property values that contain comments with braces in them --- lib/parse/index.js | 2 +- test/parse.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/parse/index.js b/lib/parse/index.js index 053f0596..1d3c084e 100644 --- a/lib/parse/index.js +++ b/lib/parse/index.js @@ -224,7 +224,7 @@ module.exports = function(css, options){ if (!match(/^:\s*/)) return error("property missing ':'"); // val - var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/); + var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|\/\*[^*]*\*+([^/*][^*]*\*+)*\/|[^};])+)/); var ret = pos({ type: 'declaration', diff --git a/test/parse.js b/test/parse.js index b39b6ee2..2819fed8 100644 --- a/test/parse.js +++ b/test/parse.js @@ -105,4 +105,16 @@ describe('parse(str)', function() { decl.parent.should.equal(rule); }); + it('should not throw if there is an { in a comment in a property value', function () { + should(function() { + parse('thing { color: red /* { */; } '); + }).not.throw(); + }); + + it('should not throw if there is an } in a comment in a property value', function () { + should(function() { + parse('thing { color: red /* } */; } '); + }).not.throw(); + }); + });