From 5c22bd98ace69ee9f03873fc000e76e3003ef169 Mon Sep 17 00:00:00 2001 From: Rens Groothuijsen Date: Thu, 30 Apr 2020 15:14:27 +0200 Subject: [PATCH] Additional check to avoid evaluating an expression if it is a comment --- lib/less/parser/parser.js | 5 +++++ test/less/errors/invalid-color-with-comment.less | 1 + test/less/errors/invalid-color-with-comment.txt | 2 ++ 3 files changed, 8 insertions(+) create mode 100644 test/less/errors/invalid-color-with-comment.less create mode 100644 test/less/errors/invalid-color-with-comment.txt diff --git a/lib/less/parser/parser.js b/lib/less/parser/parser.js index d85420e26..3f3ea563f 100644 --- a/lib/less/parser/parser.js +++ b/lib/less/parser/parser.js @@ -2321,6 +2321,11 @@ const Parser = function Parser(context, imports, fileInfo) { continue; } e = this.addition() || this.entity(); + + if (e instanceof tree.Comment) { + e = null; + } + if (e) { entities.push(e); // operations do not allow keyword "/" dimension (e.g. small/20px) so we support that here diff --git a/test/less/errors/invalid-color-with-comment.less b/test/less/errors/invalid-color-with-comment.less new file mode 100644 index 000000000..243341f0a --- /dev/null +++ b/test/less/errors/invalid-color-with-comment.less @@ -0,0 +1 @@ +.test {color: #fffff /* comment */ ;} \ No newline at end of file diff --git a/test/less/errors/invalid-color-with-comment.txt b/test/less/errors/invalid-color-with-comment.txt new file mode 100644 index 000000000..4d1c8ee04 --- /dev/null +++ b/test/less/errors/invalid-color-with-comment.txt @@ -0,0 +1,2 @@ +ParseError: Unrecognised input in {path}invalid-color-with-comment.less on line 1, column 36: +1 .test {color: #fffff /* comment */ ;}