From 70d0936b60b4a885c0f6058f51e77aecf8bd5f93 Mon Sep 17 00:00:00 2001 From: Daniel Puckowski Date: Sat, 14 Dec 2024 16:38:44 -0500 Subject: [PATCH 1/2] fix(issue:3767) variable values with periods * Fix issue with variable values with periods when unquoted by single or double quotes. --- packages/less/src/less/parser/parser.js | 15 +++++++++++++++ packages/test-data/css/_main/variables.css | 9 +++++++++ packages/test-data/less/_main/variables.less | 18 ++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/packages/less/src/less/parser/parser.js b/packages/less/src/less/parser/parser.js index b87b4d762..1fa571568 100644 --- a/packages/less/src/less/parser/parser.js +++ b/packages/less/src/less/parser/parser.js @@ -1604,6 +1604,9 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) { value = this.permissiveValue(/[;}]/); } } + else if (isVariable) { + value = this.variableValue(); + } // Try to store values as anonymous // If we need the value later we'll re-parse it in ruleset.parseValue else { @@ -1638,6 +1641,18 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) { parserInput.restore(); } }, + variableValue: function () { + let match = this.anonymousValue(); + if (match) { + return match; + } else { + const index = parserInput.i; + match = parserInput.$re(/^([^#@$+/'"*`(;{}-]*);|(^[(?!.*\n)^.#@$+/'"*`(;{}-]*)(["'])((?!.*@.*)(? Date: Sun, 15 Dec 2024 07:37:50 -0500 Subject: [PATCH 2/2] fix(issue:3767) add more variable tests * Add more variable tests for issue #3767. --- packages/test-data/css/_main/variables.css | 2 ++ packages/test-data/less/_main/variables.less | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/packages/test-data/css/_main/variables.css b/packages/test-data/css/_main/variables.css index 38c990ab8..9b822897a 100644 --- a/packages/test-data/css/_main/variables.css +++ b/packages/test-data/css/_main/variables.css @@ -88,4 +88,6 @@ m-5: a "a.ab" c c 'a.bc' abc d; m-6: a.hello; m-7: 'a.b' "abc" abc a.b.c 'a.b.c'; + m-8: hello; + m-9: 'a.hello'; } diff --git a/packages/test-data/less/_main/variables.less b/packages/test-data/less/_main/variables.less index 13385e86e..d5940472c 100644 --- a/packages/test-data/less/_main/variables.less +++ b/packages/test-data/less/_main/variables.less @@ -151,6 +151,8 @@ @mixedThree: a "a.ab" c c 'a.bc' abc d; @mixedFour: a.hello; @mixedFive: 'a.b' "abc" abc a.b.c 'a.b.c'; +@mixedSix: hello; +@mixedSeven: 'a.hello'; .mixed { m-1: @doubleQuoted; @@ -160,4 +162,6 @@ m-5: @mixedThree; m-6: @mixedFour; m-7: @mixedFive; + m-8: @mixedSix; + m-9: @mixedSeven; }