cdk8s-plus-35 2.0.8 → 2.0.9

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.
@@ -1,12 +1,12 @@
1
- var balanced = require('balanced-match');
1
+ var balanced = require('balanced-match')
2
2
 
3
- module.exports = expandTop;
3
+ module.exports = expandTop
4
4
 
5
- var escSlash = '\0SLASH'+Math.random()+'\0';
6
- var escOpen = '\0OPEN'+Math.random()+'\0';
7
- var escClose = '\0CLOSE'+Math.random()+'\0';
8
- var escComma = '\0COMMA'+Math.random()+'\0';
9
- var escPeriod = '\0PERIOD'+Math.random()+'\0';
5
+ var escSlash = '\0SLASH' + Math.random().toFixed(16) + '\0'
6
+ var escOpen = '\0OPEN' + Math.random().toFixed(16) + '\0'
7
+ var escClose = '\0CLOSE' + Math.random().toFixed(16) + '\0'
8
+ var escComma = '\0COMMA' + Math.random().toFixed(16) + '\0'
9
+ var escPeriod = '\0PERIOD' + Math.random().toFixed(16) + '\0'
10
10
 
11
11
  var EXPANSION_MAX = 100000
12
12
 
@@ -42,41 +42,155 @@ var EXPANSION_MAX_DEPTH = 1000
42
42
  // times the scan may restart. Real `{a},b}` input needs a handful.
43
43
  var EXPANSION_MAX_REWRITES = 1000
44
44
 
45
+ // `EXPANSION_MAX_STEPS` bounds the work one `expandTop` call does, which `max`,
46
+ // `maxLength` and `maxDepth` don't: nested sets are rescanned at every level
47
+ // and chained groups each rebuild up to `max` results, so 2KB of input could
48
+ // block the event loop for over 30 seconds. Each character scanned, result
49
+ // built and sequence value generated is a step, and each `expand` call costs
50
+ // `CALL_STEPS` more. Past the budget, the set being expanded and everything
51
+ // after it stay literal. A glob needs a few hundred steps, and nesting all the
52
+ // way to `EXPANSION_MAX_DEPTH` about 4M.
53
+ var EXPANSION_MAX_STEPS = 20000000
54
+
55
+ // What one `expand` call costs on top of what it scans and builds. Setting
56
+ // one up takes about as long as scanning 16 characters, and a set whose
57
+ // results are wrapped to be expanded again makes one call per result, each
58
+ // scanning and building next to nothing: 64KB of
59
+ // `('{{' + ','.repeat(316) + '}{' + ','.repeat(316) + '}}').repeat(n)` made
60
+ // 4M such calls, which spent the budget three times as slowly as anything
61
+ // else.
62
+ var CALL_STEPS = 16
63
+
45
64
  function numeric(str) {
46
- return parseInt(str, 10) == str
47
- ? parseInt(str, 10)
48
- : str.charCodeAt(0);
65
+ return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0)
49
66
  }
50
67
 
51
68
  function escapeBraces(str) {
52
- return str.split('\\\\').join(escSlash)
53
- .split('\\{').join(escOpen)
54
- .split('\\}').join(escClose)
55
- .split('\\,').join(escComma)
56
- .split('\\.').join(escPeriod);
69
+ return str
70
+ .split('\\\\')
71
+ .join(escSlash)
72
+ .split('\\{')
73
+ .join(escOpen)
74
+ .split('\\}')
75
+ .join(escClose)
76
+ .split('\\,')
77
+ .join(escComma)
78
+ .split('\\.')
79
+ .join(escPeriod)
57
80
  }
58
81
 
59
82
  function unescapeBraces(str) {
60
- return str.split(escSlash).join('\\')
61
- .split(escOpen).join('{')
62
- .split(escClose).join('}')
63
- .split(escComma).join(',')
64
- .split(escPeriod).join('.');
83
+ return str
84
+ .split(escSlash)
85
+ .join('\\')
86
+ .split(escOpen)
87
+ .join('{')
88
+ .split(escClose)
89
+ .join('}')
90
+ .split(escComma)
91
+ .join(',')
92
+ .split(escPeriod)
93
+ .join('.')
65
94
  }
66
95
 
67
-
68
96
  // Like `target.push(...items)` but doesn't overflow the stack
69
97
  function pushAll(target, items) {
70
98
  for (var i = 0; i < items.length; i++) {
71
- target.push(items[i]);
99
+ target.push(items[i])
100
+ }
101
+ }
102
+
103
+ // `budget` is `{ remaining }`, one counter shared by every level and group of
104
+ // an `expandTop` call, so the bound holds for the call as a whole.
105
+ //
106
+ // `balanced`, run on `masked` (see `maskUnmatchedOpens`), sliced from `str`
107
+ // and charged for the characters it walks: up to the group's `}`, or the
108
+ // whole string when there is no match or unmatched `{` come first, which
109
+ // `unmatched` then flags for masking. Once a call overdraws the budget, it
110
+ // and every later one return undefined, so the rest stays literal.
111
+ function balancedWithBudget(str, masked, budget) {
112
+ if (budget.remaining < 0) {
113
+ return undefined
114
+ }
115
+ var r = balanced.range('{', '}', masked)
116
+ var unmatched = r !== undefined && masked.indexOf('{') < r[0]
117
+ budget.remaining -= r && !unmatched ? r[1] + 1 : str.length
118
+ if (!r || budget.remaining < 0) {
119
+ return undefined
120
+ }
121
+ return {
122
+ end: r[1],
123
+ pre: str.slice(0, r[0]),
124
+ body: str.slice(r[0] + 1, r[1]),
125
+ post: str.slice(r[1] + 1),
126
+ unmatched: unmatched,
127
+ }
128
+ }
129
+
130
+ // `masked` with every `{` that has no matching `}` swapped for a `\0`, which
131
+ // keeps the length, so a scan of it still lines up with the string it was
132
+ // made from. Such a `{` is literal either way, but `balanced` only learns that
133
+ // one is unmatched by reading to the end of the string, so with one at the
134
+ // head of every group (`'{a,{b,c}'.repeat(n)`) each scan read the rest of the
135
+ // input. That was quadratic, and once the step budget charged for it, it ran
136
+ // out partway through and left the rest literal. A scan of the masked copy
137
+ // stops at the group's `}`. It is one pass, charged as such.
138
+ function maskUnmatchedOpens(masked, budget) {
139
+ budget.remaining -= masked.length
140
+ var open = []
141
+ for (var i = 0; i < masked.length; i++) {
142
+ var c = masked.charCodeAt(i)
143
+ if (c === 0x7b) {
144
+ open.push(i)
145
+ } else if (c === 0x7d && open.length) {
146
+ open.pop()
147
+ }
148
+ }
149
+ var out = ''
150
+ var last = 0
151
+ for (var j = 0; j < open.length; j++) {
152
+ out += masked.slice(last, open[j]) + '\0'
153
+ last = open[j] + 1
154
+ }
155
+ return out + masked.slice(last)
156
+ }
157
+
158
+ // Whether `str` has a `,` not followed by another `,`, with a `}` after it on
159
+ // the same line - what `/,(?!,).*\}/.test(str)` asks, answered in one pass from
160
+ // the end. The regex tries every `,` and backtracks through the rest of its
161
+ // line from each, which is quadratic, and the `{a},b}` rewrite asks again on
162
+ // every pass. Like a scan, it is charged for the whole string and refused if
163
+ // that overdraws the budget.
164
+ function commaSetFollows(str, budget) {
165
+ budget.remaining -= str.length
166
+ if (budget.remaining < 0) {
167
+ return false
168
+ }
169
+ // Whether a `}` follows the current position before the line ends
170
+ var close = false
171
+ for (var i = str.length - 1; i >= 0; i--) {
172
+ var c = str.charCodeAt(i)
173
+ if (c === 0x7d) {
174
+ close = true
175
+ } else if (c === 0x0a || c === 0x0d || c === 0x2028 || c === 0x2029) {
176
+ // A line terminator, which `.` does not match
177
+ close = false
178
+ } else if (c === 0x2c && close && str.charCodeAt(i + 1) !== 0x2c) {
179
+ return true
180
+ }
72
181
  }
182
+ return false
73
183
  }
74
184
 
75
185
  // Basically just str.split(","), but handling cases
76
186
  // where we have nested braced sections, which should be
77
187
  // treated as individual members, like {a,{b,c},d}
78
- function parseCommaParts(str) {
79
- var parts = [];
188
+ //
189
+ // Returns `undefined` if the step budget runs out before the whole set is
190
+ // split, since splitting what is left on every comma would tear apart the
191
+ // nested sets it still holds.
192
+ function parseCommaParts(str, budget) {
193
+ var parts = []
80
194
 
81
195
  // Walk the brace groups iteratively. Recursing on `post` once per group let a
82
196
  // chain of them exhaust the stack - the parsing-side counterpart to
@@ -84,46 +198,60 @@ function parseCommaParts(str) {
84
198
  // `maxLength` can bound, since it happens before expansion.
85
199
  //
86
200
  // The part the next chunk continues
87
- var carry = '';
201
+ var carry = ''
88
202
 
89
203
  for (;;) {
90
- var m = balanced('{', '}', str);
204
+ // A set's body holds no unmatched `{`, so there is nothing to mask.
205
+ var m = balancedWithBudget(str, str, budget)
206
+
207
+ if (budget.remaining < 0) {
208
+ return undefined
209
+ }
91
210
 
92
211
  if (!m) {
93
- var tail = str.split(',');
94
- tail[0] = carry + tail[0];
95
- pushAll(parts, tail);
96
- return parts;
212
+ var tail = str.split(',')
213
+ tail[0] = carry + tail[0]
214
+ pushAll(parts, tail)
215
+ return parts
97
216
  }
98
217
 
99
- var pre = m.pre;
100
- var body = m.body;
101
- var post = m.post;
102
- var p = pre.split(',');
218
+ var pre = m.pre
219
+ var body = m.body
220
+ var post = m.post
221
+ var p = pre.split(',')
103
222
 
104
- p[0] = carry + p[0];
105
- p[p.length-1] += '{' + body + '}';
223
+ p[0] = carry + p[0]
224
+ p[p.length - 1] += '{' + body + '}'
106
225
 
107
226
  if (!post.length) {
108
- pushAll(parts, p);
109
- return parts;
227
+ pushAll(parts, p)
228
+ return parts
110
229
  }
111
230
 
112
- carry = p.pop();
113
- pushAll(parts, p);
114
- str = post;
231
+ carry = p.pop()
232
+ pushAll(parts, p)
233
+ str = post
115
234
  }
116
235
  }
117
236
 
237
+ // An option that is left out or null, or that is NaN, gets its default. Every
238
+ // comparison against NaN is false, so a NaN bound would never be reached:
239
+ // `{ maxSteps: NaN }` let 15KB of input block the event loop for 16 seconds,
240
+ // and `{ maxDepth: NaN }` overflowed the stack again (CVE-2026-102278). Pass
241
+ // `Infinity` to lift a bound.
242
+ function bound(value, fallback) {
243
+ return value == null || isNaN(value) ? fallback : value
244
+ }
245
+
118
246
  function expandTop(str, options) {
119
- if (!str)
120
- return [];
247
+ if (!str) return []
121
248
 
122
- options = options || {};
123
- var max = options.max == null ? EXPANSION_MAX : options.max;
124
- var maxLength = options.maxLength == null ? EXPANSION_MAX_LENGTH : options.maxLength;
125
- var maxDepth = options.maxDepth == null ? EXPANSION_MAX_DEPTH : options.maxDepth;
126
- var maxRewrites = options.maxRewrites == null ? EXPANSION_MAX_REWRITES : options.maxRewrites;
249
+ options = options || {}
250
+ var max = bound(options.max, EXPANSION_MAX)
251
+ var maxLength = bound(options.maxLength, EXPANSION_MAX_LENGTH)
252
+ var maxDepth = bound(options.maxDepth, EXPANSION_MAX_DEPTH)
253
+ var maxRewrites = bound(options.maxRewrites, EXPANSION_MAX_REWRITES)
254
+ var maxSteps = bound(options.maxSteps, EXPANSION_MAX_STEPS)
127
255
 
128
256
  // I don't know why Bash 4.3 does this, but it does.
129
257
  // Anything starting with {} will have the first two bytes preserved
@@ -132,64 +260,72 @@ function expandTop(str, options) {
132
260
  // One could argue that this is a bug in Bash, but since the goal of
133
261
  // this module is to match Bash's rules, we escape a leading {}
134
262
  if (str.substr(0, 2) === '{}') {
135
- str = '\\{\\}' + str.substr(2);
263
+ str = '\\{\\}' + str.substr(2)
136
264
  }
137
265
 
138
- return expand(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, true).map(unescapeBraces);
266
+ return expand(
267
+ escapeBraces(str),
268
+ max,
269
+ maxLength,
270
+ maxDepth,
271
+ 0,
272
+ maxRewrites,
273
+ { remaining: maxSteps },
274
+ true
275
+ ).map(unescapeBraces)
139
276
  }
140
277
 
141
278
  function embrace(str) {
142
- return '{' + str + '}';
279
+ return '{' + str + '}'
143
280
  }
144
281
  function isPadded(el) {
145
- return /^-?0\d/.test(el);
282
+ return /^-?0\d/.test(el)
146
283
  }
147
284
 
148
285
  function lte(i, y) {
149
- return i <= y;
286
+ return i <= y
150
287
  }
151
288
  function gte(i, y) {
152
- return i >= y;
289
+ return i >= y
153
290
  }
154
291
 
155
292
  // Build `{ acc[a] + pre + values[v] }` for every combination, capping the
156
293
  // number of results at `max` and the total number of characters at `maxLength`.
157
294
  // This is the one place output grows, so bounding it here keeps the single
158
295
  // accumulator - and therefore memory - flat regardless of how many brace groups
159
- // are combined (CVE-2026-14257).
160
- function combine(
161
- acc,
162
- pre,
163
- values,
164
- max,
165
- maxLength,
166
- dropEmpties
167
- ) {
296
+ // are combined (CVE-2026-14257). Each result built is a step, since `max` and
297
+ // `maxLength` bound one combination, not how many brace groups are combined.
298
+ function combine(acc, pre, values, max, maxLength, dropEmpties, budget) {
168
299
  var out = []
169
300
  var length = 0
170
- for (var a = 0; a < acc.length; a++) {
171
- for (var v = 0; v < values.length; v++) {
172
- if (out.length >= max) return out
173
- var expansion = acc[a] + pre + values[v]
174
- // Bash drops empty results at the top level. Skip them before they count
175
- // against `max`, so `max` bounds the number of *kept* results.
176
- if (dropEmpties && !expansion) continue
177
- if (length + expansion.length > maxLength) return out
301
+ // Bash drops empty results at the top level, and they don't count against
302
+ // `max`, so `max` bounds the number of *kept* results. Only an empty
303
+ // `acc[a] + pre` can make one, so for those the empty values are skipped
304
+ // without being visited. Visiting them one at a time let a set of empties
305
+ // cost `acc.length * values.length` while keeping nothing.
306
+ var nonEmpty
307
+ outer: for (var a = 0; a < acc.length; a++) {
308
+ var prefix = acc[a] + pre
309
+ var vs = values
310
+ if (dropEmpties && !prefix) {
311
+ if (!nonEmpty) nonEmpty = values.filter(Boolean)
312
+ vs = nonEmpty
313
+ }
314
+ for (var v = 0; v < vs.length; v++) {
315
+ if (out.length >= max) break outer
316
+ var expansion = prefix + vs[v]
317
+ if (length + expansion.length > maxLength) break outer
178
318
  out.push(expansion)
179
319
  length += expansion.length
180
320
  }
181
321
  }
322
+ budget.remaining -= out.length
182
323
  return out
183
324
  }
184
325
 
185
326
  // The expansion values of a single numeric (`1..5`) or alphabetic (`a..e..2`)
186
- // sequence body.
187
- function expandSequence(
188
- body,
189
- isAlphaSequence,
190
- max,
191
- maxLength
192
- ) {
327
+ // sequence body, or `undefined` if the step budget runs out generating them.
328
+ function expandSequence(body, isAlphaSequence, max, maxLength, budget) {
193
329
  var n = body.split(/\.\./)
194
330
  var N = []
195
331
  // A sequence body always splits into two or three parts, but the compiler
@@ -213,9 +349,21 @@ function expandSequence(
213
349
  test = gte
214
350
  }
215
351
  var pad = n.some(isPadded)
352
+ // A padded value is built a character at a time to `width`, which the input
353
+ // sets, so it costs one step per character: 64KB of
354
+ // `('{' + '0'.repeat(100) + '..99999}').repeat(n)` took 7 seconds charged
355
+ // one step per value.
356
+ var cost = pad ? width : 1
216
357
 
217
358
  var length = 0
218
359
  for (var i = x; test(i, y) && N.length < max; i += incr) {
360
+ // Each value is a step. `max` and `maxLength` bound one sequence, but a
361
+ // chain of them still generated up to `max` values each, however few
362
+ // combining could keep.
363
+ budget.remaining -= cost
364
+ if (budget.remaining < 0) {
365
+ return undefined
366
+ }
219
367
  var c
220
368
  if (isAlphaSequence) {
221
369
  c = String.fromCharCode(i)
@@ -250,13 +398,17 @@ function expand(
250
398
  maxDepth,
251
399
  depth,
252
400
  maxRewrites,
401
+ budget,
253
402
  isTop
254
403
  ) {
404
+ // An overdraft here makes the first scan refuse, so `str` stays literal.
405
+ budget.remaining -= CALL_STEPS
406
+
255
407
  // Too deeply nested to keep following: treat the rest as literal, the same
256
408
  // way a group that cannot expand is already handled. Truncating rather than
257
409
  // throwing keeps expansion total, matching `max` and `maxLength`.
258
410
  if (depth > maxDepth) {
259
- return [str];
411
+ return [str]
260
412
  }
261
413
 
262
414
  // Consume the string's top-level brace groups left to right, threading a
@@ -276,18 +428,41 @@ function expand(
276
428
  var rewrites = 0
277
429
  var dropEmpties = false
278
430
  var firstGroup = true
431
+ // `str` with its unmatched `{` masked, once a scan has run into them
432
+ var masked = str
279
433
 
280
434
  for (;;) {
281
- const m = balanced('{', '}', str)
435
+ const m = balancedWithBudget(str, masked, budget)
282
436
 
283
- // No brace set left: the rest of the string is literal.
437
+ // No brace set left, or no step budget left to look for one: the rest of
438
+ // the string is literal.
284
439
  if (!m) {
285
- return combine(acc, str, [''], max, maxLength, dropEmpties)
440
+ return combine(acc, str, [''], max, maxLength, dropEmpties, budget)
441
+ }
442
+ if (m.unmatched) {
443
+ masked = maskUnmatchedOpens(masked, budget)
286
444
  }
287
445
 
288
446
  // no need to expand pre, since it is guaranteed to be free of brace-sets
289
447
  const pre = m.pre
290
448
 
449
+ // This set and the rest of the string, literal: for a set that cannot
450
+ // expand, and for one the step budget runs out on. Once it is overdrawn,
451
+ // every set still being expanded, at every level, stays literal like this -
452
+ // otherwise each level above would go on combining, and wrapping and
453
+ // expanding again, results the budget was too small for.
454
+ var literal = function () {
455
+ return combine(
456
+ acc,
457
+ pre + '{' + m.body + '}' + m.post,
458
+ [''],
459
+ max,
460
+ maxLength,
461
+ dropEmpties,
462
+ budget
463
+ )
464
+ }
465
+
291
466
  if (/\$$/.test(pre)) {
292
467
  acc = combine(
293
468
  acc,
@@ -295,35 +470,37 @@ function expand(
295
470
  [''],
296
471
  max,
297
472
  maxLength,
298
- dropEmpties && !m.post.length
473
+ dropEmpties && !m.post.length,
474
+ budget
299
475
  )
300
476
  firstGroup = false
301
477
  if (!m.post.length) break
302
478
  str = m.post
479
+ masked = masked.slice(m.end + 1)
303
480
  continue
304
481
  }
305
482
 
306
- var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
307
- var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
308
- var isSequence = isNumericSequence || isAlphaSequence;
309
- var isOptions = m.body.indexOf(',') >= 0;
483
+ var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body)
484
+ var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(
485
+ m.body
486
+ )
487
+ var isSequence = isNumericSequence || isAlphaSequence
488
+ var isOptions = m.body.indexOf(',') >= 0
310
489
  if (!isSequence && !isOptions) {
311
490
  // {a},b}
312
- if (rewrites < maxRewrites && m.post.match(/,(?!,).*\}/)) {
313
- rewrites++;
314
- str = m.pre + '{' + m.body + escClose + m.post;
315
- isTop = true;
316
- continue;
491
+ if (rewrites < maxRewrites && commaSetFollows(m.post, budget)) {
492
+ rewrites++
493
+ str = m.pre + '{' + m.body + escClose + m.post
494
+ // Taking a `}` away never gives an unmatched `{` a partner, so what
495
+ // is masked stays unmatched. The `{` it closed can be left without
496
+ // one, and the next scan masks it.
497
+ masked =
498
+ masked.slice(0, m.end) + escClose + masked.slice(m.end + 1)
499
+ isTop = true
500
+ continue
317
501
  }
318
502
  // Nothing here expands, so the whole remaining string is literal.
319
- return combine(
320
- acc,
321
- pre + '{' + m.body + '}' + m.post,
322
- [''],
323
- max,
324
- maxLength,
325
- dropEmpties
326
- )
503
+ return literal()
327
504
  }
328
505
 
329
506
  if (firstGroup) {
@@ -331,27 +508,59 @@ function expand(
331
508
  firstGroup = false
332
509
  }
333
510
 
334
- var values;
511
+ var values
335
512
  if (isSequence) {
336
- values = expandSequence(m.body, isAlphaSequence, max, maxLength);
513
+ values = expandSequence(
514
+ m.body,
515
+ isAlphaSequence,
516
+ max,
517
+ maxLength,
518
+ budget
519
+ )
520
+ if (!values) {
521
+ return literal()
522
+ }
337
523
  } else {
338
- var n = parseCommaParts(m.body);
524
+ var n = parseCommaParts(m.body, budget)
525
+ // The step budget ran out partway through the set.
526
+ if (!n) {
527
+ return literal()
528
+ }
339
529
  if (n.length === 1 && n[0] !== undefined) {
340
530
  // x{{a,b}}y ==> x{a}y x{b}y
341
- n = expand(n[0], max, maxLength, maxDepth, depth + 1, maxRewrites, false).map(embrace);
531
+ n = expand(
532
+ n[0],
533
+ max,
534
+ maxLength,
535
+ maxDepth,
536
+ depth + 1,
537
+ maxRewrites,
538
+ budget,
539
+ false
540
+ ).map(embrace)
541
+ // The step budget ran out expanding the set's only part.
542
+ if (budget.remaining < 0) {
543
+ return literal()
544
+ }
342
545
  //XXX is this necessary? Can't seem to hit it in tests.
343
546
  /* c8 ignore start */
344
547
  if (n.length === 1) {
345
- acc = combine(
548
+ var single = combine(
346
549
  acc,
347
550
  pre + n[0],
348
551
  [''],
349
552
  max,
350
553
  maxLength,
351
- dropEmpties && !m.post.length
554
+ dropEmpties && !m.post.length,
555
+ budget
352
556
  )
557
+ if (budget.remaining < 0) {
558
+ return literal()
559
+ }
560
+ acc = single
353
561
  if (!m.post.length) break
354
562
  str = m.post
563
+ masked = masked.slice(m.end + 1)
355
564
  continue
356
565
  }
357
566
  /* c8 ignore stop */
@@ -372,11 +581,27 @@ function expand(
372
581
  values = []
373
582
  var valuesLength = 0
374
583
  outer: for (var j = 0; j < n.length; j++) {
375
- var expanded = expand(n[j], max, maxLength, maxDepth, depth + 1, maxRewrites, false)
584
+ var expanded = expand(
585
+ n[j],
586
+ max,
587
+ maxLength,
588
+ maxDepth,
589
+ depth + 1,
590
+ maxRewrites,
591
+ budget,
592
+ false
593
+ )
594
+ // The step budget ran out expanding a member.
595
+ if (budget.remaining < 0) {
596
+ return literal()
597
+ }
376
598
  for (var k = 0; k < expanded.length; k++) {
377
599
  var v = expanded[k]
378
600
  if (dropsEmpties && !v) continue
379
- if (values.length >= max || valuesLength + v.length > maxLength) {
601
+ if (
602
+ values.length >= max ||
603
+ valuesLength + v.length > maxLength
604
+ ) {
380
605
  break outer
381
606
  }
382
607
  values.push(v)
@@ -385,9 +610,23 @@ function expand(
385
610
  }
386
611
  }
387
612
 
388
- acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length)
613
+ var next = combine(
614
+ acc,
615
+ pre,
616
+ values,
617
+ max,
618
+ maxLength,
619
+ dropEmpties && !m.post.length,
620
+ budget
621
+ )
622
+ // The step budget ran out combining the set's values in.
623
+ if (budget.remaining < 0) {
624
+ return literal()
625
+ }
626
+ acc = next
389
627
  if (!m.post.length) break
390
628
  str = m.post
629
+ masked = masked.slice(m.end + 1)
391
630
  }
392
631
 
393
632
  return acc
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "brace-expansion",
3
3
  "description": "Brace expansion as known from sh/bash",
4
- "version": "2.1.7",
4
+ "version": "2.1.8",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git://github.com/juliangruber/brace-expansion.git"
@@ -11,13 +11,16 @@
11
11
  "scripts": {
12
12
  "test": "tape test/*.js",
13
13
  "gentest": "bash test/generate.sh",
14
- "bench": "matcha test/perf/bench.js"
14
+ "bench": "matcha test/perf/bench.js",
15
+ "format": "prettier --write .",
16
+ "format:check": "prettier --check ."
15
17
  },
16
18
  "dependencies": {
17
19
  "balanced-match": "^1.0.0"
18
20
  },
19
21
  "devDependencies": {
20
22
  "@c4312/matcha": "^1.3.1",
23
+ "prettier": "^3.9.8",
21
24
  "tape": "^4.6.0"
22
25
  },
23
26
  "keywords": [],
package/package.json CHANGED
@@ -102,7 +102,7 @@
102
102
  "publishConfig": {
103
103
  "access": "public"
104
104
  },
105
- "version": "2.0.8",
105
+ "version": "2.0.9",
106
106
  "jest": {
107
107
  "coverageProvider": "v8",
108
108
  "testMatch": [
@@ -1,2 +0,0 @@
1
- tidelift: "npm/brace-expansion"
2
- patreon: juliangruber