Skip to content

Commit

Permalink
Fixes #3423 #3420 (#3424)
Browse files Browse the repository at this point in the history
* Fixes #3423 #3420
* Proper fix without reverting previous fix
  • Loading branch information
matthew-dean committed Aug 22, 2019
1 parent f454ab7 commit 91fd4c3
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 30 deletions.
15 changes: 9 additions & 6 deletions bin/lessc
Expand Up @@ -8834,8 +8834,11 @@ var Parser = function Parser(context, imports, fileInfo) {
result = parsers[p]();

if (result) {
result._index = i + currentIndex;
result._fileInfo = fileInfo;
try {
result._index = i + currentIndex;
result._fileInfo = fileInfo;
} catch (e) {}

returnNodes.push(result);
} else {
returnNodes.push(null);
Expand Down Expand Up @@ -11858,8 +11861,8 @@ var list = {
return n;
},
extract: function extract(values, index) {
index = index.value - 1; // (1-based index)

// (1-based index)
index = index.value - 1;
return getItemsFromNode(values)[index];
},
length: function length(values) {
Expand Down Expand Up @@ -12132,7 +12135,7 @@ var number$1 = {

var string = {
e: function e(str) {
return new Quoted('"', str instanceof JavaScript ? str.evaluated : str.value, true);
return new Anonymous(str instanceof JavaScript ? str.evaluated : str.value);
},
escape: function escape(str) {
return new Anonymous(encodeURI(str.value).replace(/=/g, '%3D').replace(/:/g, '%3A').replace(/#/g, '%23').replace(/;/g, '%3B').replace(/\(/g, '%28').replace(/\)/g, '%29'));
Expand Down Expand Up @@ -13362,7 +13365,7 @@ var createFromEnvironment = (function (environment, fileManagers) {
*/

var initial = {
version: [3, 10, 2],
version: [3, 10, 3],
data,
tree,
Environment: environment$1,
Expand Down
15 changes: 9 additions & 6 deletions dist/less.cjs.js
Expand Up @@ -8830,8 +8830,11 @@ var Parser = function Parser(context, imports, fileInfo) {
result = parsers[p]();

if (result) {
result._index = i + currentIndex;
result._fileInfo = fileInfo;
try {
result._index = i + currentIndex;
result._fileInfo = fileInfo;
} catch (e) {}

returnNodes.push(result);
} else {
returnNodes.push(null);
Expand Down Expand Up @@ -11854,8 +11857,8 @@ var list = {
return n;
},
extract: function extract(values, index) {
index = index.value - 1; // (1-based index)

// (1-based index)
index = index.value - 1;
return getItemsFromNode(values)[index];
},
length: function length(values) {
Expand Down Expand Up @@ -12128,7 +12131,7 @@ var number$1 = {

var string = {
e: function e(str) {
return new Quoted('"', str instanceof JavaScript ? str.evaluated : str.value, true);
return new Anonymous(str instanceof JavaScript ? str.evaluated : str.value);
},
escape: function escape(str) {
return new Anonymous(encodeURI(str.value).replace(/=/g, '%3D').replace(/:/g, '%3A').replace(/#/g, '%23').replace(/;/g, '%3B').replace(/\(/g, '%28').replace(/\)/g, '%29'));
Expand Down Expand Up @@ -13358,7 +13361,7 @@ var createFromEnvironment = (function (environment, fileManagers) {
*/

var initial = {
version: [3, 10, 2],
version: [3, 10, 3],
data,
tree,
Environment: environment$1,
Expand Down
17 changes: 10 additions & 7 deletions dist/less.js
@@ -1,5 +1,5 @@
/**
* Less - Leaner CSS v3.10.2
* Less - Leaner CSS v3.10.3
* http://lesscss.org
*
* Copyright (c) 2009-2019, Alexis Sellier <self@cloudhead.net>
Expand Down Expand Up @@ -8999,8 +8999,11 @@
result = parsers[p]();

if (result) {
result._index = i + currentIndex;
result._fileInfo = fileInfo;
try {
result._index = i + currentIndex;
result._fileInfo = fileInfo;
} catch (e) {}

returnNodes.push(result);
} else {
returnNodes.push(null);
Expand Down Expand Up @@ -12022,8 +12025,8 @@
return n;
},
extract: function extract(values, index) {
index = index.value - 1; // (1-based index)

// (1-based index)
index = index.value - 1;
return getItemsFromNode(values)[index];
},
length: function length(values) {
Expand Down Expand Up @@ -12296,7 +12299,7 @@

var string = {
e: function e(str) {
return new Quoted('"', str instanceof JavaScript ? str.evaluated : str.value, true);
return new Anonymous(str instanceof JavaScript ? str.evaluated : str.value);
},
escape: function escape(str) {
return new Anonymous(encodeURI(str.value).replace(/=/g, '%3D').replace(/:/g, '%3A').replace(/#/g, '%23').replace(/;/g, '%3B').replace(/\(/g, '%28').replace(/\)/g, '%29'));
Expand Down Expand Up @@ -13526,7 +13529,7 @@
*/

var initial = {
version: [3, 10, 2],
version: [3, 10, 3],
data: data,
tree: tree,
Environment: environment,
Expand Down
4 changes: 2 additions & 2 deletions 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.

3 changes: 2 additions & 1 deletion lib/less/functions/list.js
Expand Up @@ -21,7 +21,8 @@ export default {
return n;
},
extract: function(values, index) {
index = index.value - 1; // (1-based index)
// (1-based index)
index = index.value - 1;

return getItemsFromNode(values)[index];
},
Expand Down
3 changes: 1 addition & 2 deletions lib/less/functions/string.js
@@ -1,11 +1,10 @@
import Quoted from '../tree/quoted';
import Anonymous from '../tree/anonymous';
import Quote from '../tree/quoted';
import JavaScript from '../tree/javascript';

export default {
e: function (str) {
return new Quote('"', str instanceof JavaScript ? str.evaluated : str.value, true);
return new Quoted('"', str instanceof JavaScript ? str.evaluated : str.value, true);
},
escape: function (str) {
return new Anonymous(
Expand Down
2 changes: 1 addition & 1 deletion lib/less/index.js
Expand Up @@ -42,7 +42,7 @@ export default (environment, fileManagers) => {
* It's not clear what should / must be public and why.
*/
const initial = {
version: [3, 10, 2],
version: [3, 10, 3],
data,
tree,
Environment,
Expand Down
6 changes: 4 additions & 2 deletions lib/less/parser/parser.js
Expand Up @@ -107,8 +107,10 @@ const Parser = function Parser(context, imports, fileInfo) {
i = parser.i;
result = parsers[p]();
if (result) {
result._index = i + currentIndex;
result._fileInfo = fileInfo;
try {
result._index = i + currentIndex;
result._fileInfo = fileInfo;
} catch (e) {}
returnNodes.push(result);
}
else {
Expand Down
3 changes: 3 additions & 0 deletions lib/less/tree/quoted.js
Expand Up @@ -2,6 +2,7 @@ import Node from './node';
import Variable from './variable';
import Property from './property';


class Quoted extends Node {
constructor(str, content, escaped, index, currentFileInfo) {
super();
Expand All @@ -13,6 +14,7 @@ class Quoted extends Node {
this._fileInfo = currentFileInfo;
this.variableRegex = /@\{([\w-]+)\}/g;
this.propRegex = /\$\{([\w-]+)\}/g;
this.allowRoot = escaped;
}

genCSS(context, output) {
Expand Down Expand Up @@ -50,6 +52,7 @@ class Quoted extends Node {
}
value = iterativeReplace(value, this.variableRegex, variableReplacement);
value = iterativeReplace(value, this.propRegex, propertyReplacement);

return new Quoted(this.quote + value + this.quote, value, this.escaped, this.getIndex(), this.fileInfo());
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "less",
"version": "3.10.2",
"version": "3.10.3",
"description": "Leaner CSS",
"homepage": "http://lesscss.org",
"author": {
Expand Down
1 change: 1 addition & 0 deletions test/css/css-escapes.css
Expand Up @@ -28,3 +28,4 @@ ng\:form {
textarea {
font-family: 'helvetica neue', 'wenquanyi micro hei', \5FAE\8F6F\96C5\9ED1, \5B8B\4F53, sans-serif;
}
anything to unquote
4 changes: 3 additions & 1 deletion test/less/css-escapes.less
Expand Up @@ -39,4 +39,6 @@ ng\:form {

textarea {
font-family: 'helvetica neue','wenquanyi micro hei',\5FAE\8F6F\96C5\9ED1, \5B8B\4F53, sans-serif;
}
}

e('anything to unquote');

0 comments on commit 91fd4c3

Please sign in to comment.