Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing of property values that contain comments with braces in them #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/parse/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
12 changes: 12 additions & 0 deletions test/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

});