@herb-tools/tailwind-class-sorter 0.9.5 → 0.9.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -897,6 +897,18 @@ function requireStringifier () {
897
897
  if (hasRequiredStringifier) return stringifier;
898
898
  hasRequiredStringifier = 1;
899
899
 
900
+ // Escapes sequences that could break out of an HTML <style> context.
901
+ // Uses CSS unicode escaping (\3c = '<') which is valid CSS and parsed
902
+ // correctly by all compliant CSS consumers.
903
+ const STYLE_TAG = /(<)(\/?style\b)/gi;
904
+ const COMMENT_OPEN = /(<)(!--)/g;
905
+
906
+ function escapeHTMLInCSS(str) {
907
+ if (typeof str !== 'string') return str
908
+ if (!str.includes('<')) return str
909
+ return str.replace(STYLE_TAG, '\\3c $2').replace(COMMENT_OPEN, '\\3c $2')
910
+ }
911
+
900
912
  const DEFAULT_RAW = {
901
913
  after: '\n',
902
914
  beforeClose: '\n',
@@ -935,7 +947,7 @@ function requireStringifier () {
935
947
  this.block(node, name + params);
936
948
  } else {
937
949
  let end = (node.raws.between || '') + (semicolon ? ';' : '');
938
- this.builder(name + params + end, node);
950
+ this.builder(escapeHTMLInCSS(name + params + end), node);
939
951
  }
940
952
  }
941
953
 
@@ -970,7 +982,7 @@ function requireStringifier () {
970
982
 
971
983
  block(node, start) {
972
984
  let between = this.raw(node, 'between', 'beforeOpen');
973
- this.builder(start + between + '{', node, 'start');
985
+ this.builder(escapeHTMLInCSS(start + between) + '{', node, 'start');
974
986
 
975
987
  let after;
976
988
  if (node.nodes && node.nodes.length) {
@@ -980,7 +992,7 @@ function requireStringifier () {
980
992
  after = this.raw(node, 'after', 'emptyBody');
981
993
  }
982
994
 
983
- if (after) this.builder(after);
995
+ if (after) this.builder(escapeHTMLInCSS(after));
984
996
  this.builder('}', node, 'end');
985
997
  }
986
998
 
@@ -992,10 +1004,11 @@ function requireStringifier () {
992
1004
  }
993
1005
 
994
1006
  let semicolon = this.raw(node, 'semicolon');
1007
+ let isDocument = node.type === 'document';
995
1008
  for (let i = 0; i < node.nodes.length; i++) {
996
1009
  let child = node.nodes[i];
997
1010
  let before = this.raw(child, 'before');
998
- if (before) this.builder(before);
1011
+ if (before) this.builder(isDocument ? before : escapeHTMLInCSS(before));
999
1012
  this.stringify(child, last !== i || semicolon);
1000
1013
  }
1001
1014
  }
@@ -1003,7 +1016,7 @@ function requireStringifier () {
1003
1016
  comment(node) {
1004
1017
  let left = this.raw(node, 'left', 'commentLeft');
1005
1018
  let right = this.raw(node, 'right', 'commentRight');
1006
- this.builder('/*' + left + node.text + right + '*/', node);
1019
+ this.builder(escapeHTMLInCSS('/*' + left + node.text + right + '*/'), node);
1007
1020
  }
1008
1021
 
1009
1022
  decl(node, semicolon) {
@@ -1015,7 +1028,7 @@ function requireStringifier () {
1015
1028
  }
1016
1029
 
1017
1030
  if (semicolon) string += ';';
1018
- this.builder(string, node);
1031
+ this.builder(escapeHTMLInCSS(string), node);
1019
1032
  }
1020
1033
 
1021
1034
  document(node) {
@@ -1221,13 +1234,17 @@ function requireStringifier () {
1221
1234
 
1222
1235
  root(node) {
1223
1236
  this.body(node);
1224
- if (node.raws.after) this.builder(node.raws.after);
1237
+ if (node.raws.after) {
1238
+ let after = node.raws.after;
1239
+ let isDocument = node.parent && node.parent.type === 'document';
1240
+ this.builder(isDocument ? after : escapeHTMLInCSS(after));
1241
+ }
1225
1242
  }
1226
1243
 
1227
1244
  rule(node) {
1228
1245
  this.block(node, this.rawValue(node, 'selector'));
1229
1246
  if (node.raws.ownSemicolon) {
1230
- this.builder(node.raws.ownSemicolon, node, 'end');
1247
+ this.builder(escapeHTMLInCSS(node.raws.ownSemicolon), node, 'end');
1231
1248
  }
1232
1249
  }
1233
1250
 
@@ -5845,7 +5862,8 @@ function requirePreviousMap () {
5845
5862
  return fromBase64(text.substr(baseUriMatch[0].length))
5846
5863
  }
5847
5864
 
5848
- let encoding = text.match(/data:application\/json;([^,]+),/)[1];
5865
+ let encoding = text.slice('data:application/json;'.length);
5866
+ encoding = encoding.slice(0, encoding.indexOf(','));
5849
5867
  throw new Error('Unsupported source map encoding ' + encoding)
5850
5868
  }
5851
5869
 
@@ -6088,7 +6106,15 @@ function requireInput () {
6088
6106
  );
6089
6107
  }
6090
6108
 
6091
- result.input = { column, endColumn, endLine, endOffset, line, offset, source: this.css };
6109
+ result.input = {
6110
+ column,
6111
+ endColumn,
6112
+ endLine,
6113
+ endOffset,
6114
+ line,
6115
+ offset,
6116
+ source: this.css
6117
+ };
6092
6118
  if (this.file) {
6093
6119
  if (pathToFileURL) {
6094
6120
  result.input.url = pathToFileURL(this.file).toString();
@@ -8181,7 +8207,7 @@ function requireNoWorkResult () {
8181
8207
 
8182
8208
  let MapGenerator = requireMapGenerator();
8183
8209
  let parse = requireParse$1();
8184
- const Result = requireResult();
8210
+ let Result = requireResult();
8185
8211
  let stringify = requireStringify$1();
8186
8212
  let warnOnce = requireWarnOnce();
8187
8213
 
@@ -8331,7 +8357,7 @@ function requireProcessor () {
8331
8357
 
8332
8358
  class Processor {
8333
8359
  constructor(plugins = []) {
8334
- this.version = '8.5.8';
8360
+ this.version = '8.5.10';
8335
8361
  this.plugins = this.normalize(plugins);
8336
8362
  }
8337
8363