Skip to content

Commit

Permalink
fix(parser): fix crash when css variable property does not end with a…
Browse files Browse the repository at this point in the history
… semicolon

Fixes less#3698 less#3373
  • Loading branch information
b-kelly committed Mar 9, 2022
1 parent 3f05b5c commit 1e62fae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/less/src/less/parser/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ const Parser = function Parser(context, imports, fileInfo) {

// Custom property values get permissive parsing
if (name[0].value && name[0].value.slice(0, 2) === '--') {
value = this.permissiveValue();
value = this.permissiveValue(/[;}]/);
}
// Try to store values as anonymous
// If we need the value later we'll re-parse it in ruleset.parseValue
Expand Down
9 changes: 9 additions & 0 deletions packages/test-data/css/_main/permissive-parse.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,12 @@ foo[attr="blah"] {
--value: a /* { ; } */;
--comment-within: ( /* okay?; comment; */ );
}
.test-no-trailing-semicolon {
--value: blue;
}
.test-no-trailing-semicolon2 {
--value: blue;
}
.test-no-trailing-semicolon3 {
--value: blue;
}
7 changes: 6 additions & 1 deletion packages/test-data/less/_main/permissive-parse.less
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,9 @@
.test-rule-comment {
--value: a/* { ; } */;
--comment-within: ( /* okay?; comment; */ );
}
}
.test-no-trailing-semicolon {
--value: blue
}
.test-no-trailing-semicolon2 {--value: blue}
.test-no-trailing-semicolon3 { --value: blue }

0 comments on commit 1e62fae

Please sign in to comment.