Skip to content

Commit 0e99701

Browse files
authored
fix(parser): fix crash when css variable property does not end with a semicolon (#3700)
Fixes #3698 #3373
1 parent eefe33a commit 0e99701

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

packages/less/src/less/parser/parser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1551,7 +1551,7 @@ const Parser = function Parser(context, imports, fileInfo) {
15511551

15521552
// Custom property values get permissive parsing
15531553
if (name[0].value && name[0].value.slice(0, 2) === '--') {
1554-
value = this.permissiveValue();
1554+
value = this.permissiveValue(/[;}]/);
15551555
}
15561556
// Try to store values as anonymous
15571557
// If we need the value later we'll re-parse it in ruleset.parseValue

packages/test-data/css/_main/permissive-parse.css

+9
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,12 @@ foo[attr="blah"] {
3535
--value: a /* { ; } */;
3636
--comment-within: ( /* okay?; comment; */ );
3737
}
38+
.test-no-trailing-semicolon {
39+
--value: foo;
40+
}
41+
.test-no-trailing-semicolon2 {
42+
--value: foo;
43+
}
44+
.test-no-trailing-semicolon3 {
45+
--value: foo;
46+
}

packages/test-data/less/_main/permissive-parse.less

+6-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,9 @@
4747
.test-rule-comment {
4848
--value: a/* { ; } */;
4949
--comment-within: ( /* okay?; comment; */ );
50-
}
50+
}
51+
.test-no-trailing-semicolon {
52+
--value: foo
53+
}
54+
.test-no-trailing-semicolon2 {--value: foo}
55+
.test-no-trailing-semicolon3 { --value: foo }

0 commit comments

Comments
 (0)