Skip to content

Commit

Permalink
fix(issue:4211) parse entities in comma list
Browse files Browse the repository at this point in the history
correctly parse all entities in a comma separated list such that all
URLs are rewritten correctly
  • Loading branch information
puckowski committed Aug 20, 2023
1 parent 6390ae3 commit 6897a19
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 7 deletions.
11 changes: 10 additions & 1 deletion dist/less.js
Expand Up @@ -4706,6 +4706,10 @@
if (e) {
value.push(e);
}
if (parserInput.peek(',')) {
value.push(new (tree.Anonymous)(',', parserInput.i));
parserInput.$char(',');
}
} while (e);
done = testCurrentChar();
if (value.length > 0) {
Expand Down Expand Up @@ -7125,7 +7129,12 @@
for (var i_1 = 0; i_1 < this.value.length; i_1++) {
this.value[i_1].genCSS(context, output);
if (!this.noSpacing && i_1 + 1 < this.value.length) {
output.add(' ');
if (!this.noSpacing && i_1 + 1 < this.value.length) {
if (i_1 + 1 < this.value.length && !(this.value[i_1 + 1] instanceof Anonymous) ||
this.value[i_1 + 1] instanceof Anonymous && this.value[i_1 + 1].value !== ',') {
output.add(' ');
}
}
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion dist/less.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/less.min.js.map

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion packages/less/dist/less.js
Expand Up @@ -4706,6 +4706,10 @@
if (e) {
value.push(e);
}
if (parserInput.peek(',')) {
value.push(new (tree.Anonymous)(',', parserInput.i));
parserInput.$char(',');
}
} while (e);
done = testCurrentChar();
if (value.length > 0) {
Expand Down Expand Up @@ -7125,7 +7129,12 @@
for (var i_1 = 0; i_1 < this.value.length; i_1++) {
this.value[i_1].genCSS(context, output);
if (!this.noSpacing && i_1 + 1 < this.value.length) {
output.add(' ');
if (!this.noSpacing && i_1 + 1 < this.value.length) {
if (i_1 + 1 < this.value.length && !(this.value[i_1 + 1] instanceof Anonymous) ||
this.value[i_1 + 1] instanceof Anonymous && this.value[i_1 + 1].value !== ',') {
output.add(' ');
}
}
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/less/dist/less.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/less/dist/less.min.js.map

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions packages/less/src/less/parser/parser.js
Expand Up @@ -1625,6 +1625,10 @@ const Parser = function Parser(context, imports, fileInfo, currentIndex) {
if (e) {
value.push(e);
}
if (parserInput.peek(',')) {
value.push(new (tree.Anonymous)(',', parserInput.i));
parserInput.$char(',');
}
} while (e);

done = testCurrentChar();
Expand Down
8 changes: 7 additions & 1 deletion packages/less/src/less/tree/expression.js
Expand Up @@ -2,6 +2,7 @@ import Node from './node';
import Paren from './paren';
import Comment from './comment';
import Dimension from './dimension';
import Anonymous from './anonymous';

const Expression = function(value, noSpacing) {
this.value = value;
Expand Down Expand Up @@ -56,7 +57,12 @@ Expression.prototype = Object.assign(new Node(), {
for (let i = 0; i < this.value.length; i++) {
this.value[i].genCSS(context, output);
if (!this.noSpacing && i + 1 < this.value.length) {
output.add(' ');
if (!this.noSpacing && i + 1 < this.value.length) {
if (i + 1 < this.value.length && !(this.value[i + 1] instanceof Anonymous) ||
this.value[i + 1] instanceof Anonymous && this.value[i + 1].value !== ',') {
output.add(' ');
}
}
}
}
},
Expand Down

0 comments on commit 6897a19

Please sign in to comment.