nodal-agents 0.8.0 → 0.8.1
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.
- package/node_modules/brace-expansion/README.md +23 -1
- package/node_modules/brace-expansion/index.js +250 -77
- package/node_modules/brace-expansion/package.json +1 -1
- package/node_modules/readdir-glob/node_modules/brace-expansion/README.md +23 -1
- package/node_modules/readdir-glob/node_modules/brace-expansion/index.js +206 -85
- package/node_modules/readdir-glob/node_modules/brace-expansion/package.json +1 -1
- package/package.json +1 -1
- package/runner.js +1 -1
- package/web/.next/BUILD_ID +1 -1
- package/web/.next/app-path-routes-manifest.json +9 -9
- package/web/.next/build-manifest.json +2 -2
- package/web/.next/required-server-files.json +1 -1
- package/web/.next/server/app/(dashboard)/agents/[id]/channels/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/agents/[id]/edit/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/agents/[id]/telegram/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/agents/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/approvals/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/automations/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/chat/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/connectors/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/credentials/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/jobs/[id]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/jobs/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/learned-skills/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/llm-providers/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/logs/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/mcp/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/memories/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/settings/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/settings/root-context/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/skills/[id]/edit/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/skills/new/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/skills/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/_global-error.html +1 -1
- package/web/.next/server/app/_global-error.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/_not-found.html +1 -1
- package/web/.next/server/app/_not-found.rsc +1 -1
- package/web/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/web/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/web/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/web/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/web/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/web/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/onboarding/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app-paths-manifest.json +9 -9
- package/web/.next/server/chunks/2575.js +1 -0
- package/web/.next/server/chunks/2805.js +1 -0
- package/web/.next/server/chunks/3721.js +1 -0
- package/web/.next/server/chunks/4473.js +1 -0
- package/web/.next/server/chunks/5773.js +3 -0
- package/web/.next/server/chunks/8909.js +1 -0
- package/web/.next/server/chunks/9884.js +1 -0
- package/web/.next/server/interception-route-rewrite-manifest.js +1 -0
- package/web/.next/server/middleware-build-manifest.js +1 -1
- package/web/.next/server/middleware.js.nft.json +1 -0
- package/web/.next/server/pages/404.html +1 -1
- package/web/.next/server/pages/500.html +1 -1
- package/web/.next/server/server-reference-manifest.js +1 -1
- package/web/.next/server/server-reference-manifest.json +1 -1
- package/web/server.js +1 -1
- package/node_modules/brace-expansion/.tap/coverage/8b906b8c-e21f-40b5-8c0d-214d8c2682c5.json +0 -757
- package/node_modules/brace-expansion/.tap/processinfo/8b906b8c-e21f-40b5-8c0d-214d8c2682c5.json +0 -719
- package/node_modules/brace-expansion/ADVISORY-CVE-2026-14257.md +0 -107
- package/node_modules/brace-expansion/dist/commonjs/index.d.ts +0 -8
- package/node_modules/brace-expansion/dist/commonjs/index.d.ts.map +0 -1
- package/node_modules/brace-expansion/dist/commonjs/index.js +0 -263
- package/node_modules/brace-expansion/dist/commonjs/index.js.map +0 -1
- package/node_modules/brace-expansion/dist/commonjs/package.json +0 -3
- package/node_modules/brace-expansion/dist/esm/index.d.ts +0 -8
- package/node_modules/brace-expansion/dist/esm/index.d.ts.map +0 -1
- package/node_modules/brace-expansion/dist/esm/index.js +0 -259
- package/node_modules/brace-expansion/dist/esm/index.js.map +0 -1
- package/node_modules/brace-expansion/dist/esm/package.json +0 -3
- package/node_modules/readdir-glob/node_modules/brace-expansion/.tap/coverage/8b906b8c-e21f-40b5-8c0d-214d8c2682c5.json +0 -757
- package/node_modules/readdir-glob/node_modules/brace-expansion/.tap/processinfo/8b906b8c-e21f-40b5-8c0d-214d8c2682c5.json +0 -719
- package/node_modules/readdir-glob/node_modules/brace-expansion/ADVISORY-CVE-2026-14257.md +0 -107
- package/node_modules/readdir-glob/node_modules/brace-expansion/dist/commonjs/index.d.ts +0 -8
- package/node_modules/readdir-glob/node_modules/brace-expansion/dist/commonjs/index.d.ts.map +0 -1
- package/node_modules/readdir-glob/node_modules/brace-expansion/dist/commonjs/index.js +0 -263
- package/node_modules/readdir-glob/node_modules/brace-expansion/dist/commonjs/index.js.map +0 -1
- package/node_modules/readdir-glob/node_modules/brace-expansion/dist/commonjs/package.json +0 -3
- package/node_modules/readdir-glob/node_modules/brace-expansion/dist/esm/index.d.ts +0 -8
- package/node_modules/readdir-glob/node_modules/brace-expansion/dist/esm/index.d.ts.map +0 -1
- package/node_modules/readdir-glob/node_modules/brace-expansion/dist/esm/index.js +0 -259
- package/node_modules/readdir-glob/node_modules/brace-expansion/dist/esm/index.js.map +0 -1
- package/node_modules/readdir-glob/node_modules/brace-expansion/dist/esm/package.json +0 -3
- /package/web/.next/static/{-ZFQ5_gc3weAZTV_iNuDl → u0-ztHjuJVkGZhaZljkjn}/_buildManifest.js +0 -0
- /package/web/.next/static/{-ZFQ5_gc3weAZTV_iNuDl → u0-ztHjuJVkGZhaZljkjn}/_ssgManifest.js +0 -0
|
@@ -51,11 +51,33 @@ expand('ppp{,config,oe{,conf}}')
|
|
|
51
51
|
var expand = require('brace-expansion');
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
### var expanded = expand(str)
|
|
54
|
+
### var expanded = expand(str, [options])
|
|
55
55
|
|
|
56
56
|
Return an array of all possible and valid expansions of `str`. If none are
|
|
57
57
|
found, `[str]` is returned.
|
|
58
58
|
|
|
59
|
+
The `options` object can provide a `max` value to cap the number
|
|
60
|
+
of expansions allowed. This is limited to `100_000` by default,
|
|
61
|
+
to prevent DoS attacks.
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
const expansions = expand('{1..100}'.repeat(5), {
|
|
65
|
+
max: 100,
|
|
66
|
+
})
|
|
67
|
+
// expansions.length will be 100, not 100^5
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The `options` object can also provide a `maxLength` value to cap the
|
|
71
|
+
total number of characters across all expansions. This is limited to
|
|
72
|
+
`4_000_000` by default, to prevent memory exhaustion from inputs whose
|
|
73
|
+
result count stays under `max` while each result grows very long.
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
const expansions = expand('{a,b}'.repeat(1500), {
|
|
77
|
+
maxLength: 10_000,
|
|
78
|
+
})
|
|
79
|
+
```
|
|
80
|
+
|
|
59
81
|
Valid expansions are:
|
|
60
82
|
|
|
61
83
|
```js
|
|
@@ -9,6 +9,20 @@ var escClose = '\0CLOSE'+Math.random()+'\0';
|
|
|
9
9
|
var escComma = '\0COMMA'+Math.random()+'\0';
|
|
10
10
|
var escPeriod = '\0PERIOD'+Math.random()+'\0';
|
|
11
11
|
|
|
12
|
+
var EXPANSION_MAX = 100000
|
|
13
|
+
|
|
14
|
+
// `EXPANSION_MAX` caps the *number* of expansions, but not their length. An
|
|
15
|
+
// input like `'{a,b}'.repeat(1500)` stays under that count - its output is
|
|
16
|
+
// truncated to 100k results - while making every result ~1500 characters
|
|
17
|
+
// long. The result set, and the intermediate arrays built while combining
|
|
18
|
+
// brace sets, then grow large enough to exhaust memory and crash the process
|
|
19
|
+
// (CVE-2026-14257). `EXPANSION_MAX_LENGTH` bounds the total number of
|
|
20
|
+
// characters the accumulator may hold at any point, so memory stays flat no
|
|
21
|
+
// matter how many brace groups are chained. The limit sits well above any
|
|
22
|
+
// realistic expansion (100k results hitting `EXPANSION_MAX` measure ~1M
|
|
23
|
+
// characters) so legitimate input is unaffected.
|
|
24
|
+
var EXPANSION_MAX_LENGTH = 4000000
|
|
25
|
+
|
|
12
26
|
function numeric(str) {
|
|
13
27
|
return parseInt(str, 10) == str
|
|
14
28
|
? parseInt(str, 10)
|
|
@@ -67,7 +81,8 @@ function expandTop(str, options) {
|
|
|
67
81
|
return [];
|
|
68
82
|
|
|
69
83
|
options = options || {};
|
|
70
|
-
var max = options.max == null ?
|
|
84
|
+
var max = options.max == null ? EXPANSION_MAX : options.max;
|
|
85
|
+
var maxLength = options.maxLength == null ? EXPANSION_MAX_LENGTH : options.maxLength;
|
|
71
86
|
|
|
72
87
|
// I don't know why Bash 4.3 does this, but it does.
|
|
73
88
|
// Anything starting with {} will have the first two bytes preserved
|
|
@@ -79,7 +94,7 @@ function expandTop(str, options) {
|
|
|
79
94
|
str = '\\{\\}' + str.substr(2);
|
|
80
95
|
}
|
|
81
96
|
|
|
82
|
-
return expand(escapeBraces(str), max, true).map(unescapeBraces);
|
|
97
|
+
return expand(escapeBraces(str), max, maxLength, true).map(unescapeBraces);
|
|
83
98
|
}
|
|
84
99
|
|
|
85
100
|
function identity(e) {
|
|
@@ -100,15 +115,155 @@ function gte(i, y) {
|
|
|
100
115
|
return i >= y;
|
|
101
116
|
}
|
|
102
117
|
|
|
103
|
-
|
|
104
|
-
|
|
118
|
+
// Build `{ acc[a] + pre + values[v] }` for every combination, capping the
|
|
119
|
+
// number of results at `max` and the total number of characters at `maxLength`.
|
|
120
|
+
// This is the one place output grows, so bounding it here keeps the single
|
|
121
|
+
// accumulator - and therefore memory - flat regardless of how many brace groups
|
|
122
|
+
// are combined (CVE-2026-14257).
|
|
123
|
+
//
|
|
124
|
+
// `base[a]` is the length of the part of `acc[a]` that predates the current
|
|
125
|
+
// empty-drop baseline (see `expand`). The matching baselines for the results
|
|
126
|
+
// are appended to `outBase`, which the caller carries forward alongside them.
|
|
127
|
+
function combine(
|
|
128
|
+
acc,
|
|
129
|
+
base,
|
|
130
|
+
pre,
|
|
131
|
+
values,
|
|
132
|
+
max,
|
|
133
|
+
maxLength,
|
|
134
|
+
dropEmpties,
|
|
135
|
+
outBase
|
|
136
|
+
) {
|
|
137
|
+
var out = []
|
|
138
|
+
var length = 0
|
|
139
|
+
for (var a = 0; a < acc.length; a++) {
|
|
140
|
+
for (var v = 0; v < values.length; v++) {
|
|
141
|
+
if (out.length >= max) return out
|
|
142
|
+
var expansion = acc[a] + pre + values[v]
|
|
143
|
+
// Bash drops empty results at the top level. Skip them before they count
|
|
144
|
+
// against `max`, so `max` bounds the number of *kept* results. "Empty"
|
|
145
|
+
// means "adds nothing past the baseline", not "empty overall".
|
|
146
|
+
if (dropEmpties && expansion.length === base[a]) continue
|
|
147
|
+
if (length + expansion.length > maxLength) return out
|
|
148
|
+
out.push(expansion)
|
|
149
|
+
outBase.push(base[a])
|
|
150
|
+
length += expansion.length
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return out
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// The expansion values of a single numeric (`1..5`) or alphabetic (`a..e..2`)
|
|
157
|
+
// sequence body.
|
|
158
|
+
function expandSequence(
|
|
159
|
+
body,
|
|
160
|
+
isAlphaSequence,
|
|
161
|
+
max,
|
|
162
|
+
maxLength
|
|
163
|
+
) {
|
|
164
|
+
var n = body.split(/\.\./)
|
|
165
|
+
var N = []
|
|
166
|
+
// A sequence body always splits into two or three parts, but the compiler
|
|
167
|
+
// can't know that.
|
|
168
|
+
/* c8 ignore start */
|
|
169
|
+
if (n[0] === undefined || n[1] === undefined) {
|
|
170
|
+
return N
|
|
171
|
+
}
|
|
172
|
+
/* c8 ignore stop */
|
|
173
|
+
var x = numeric(n[0])
|
|
174
|
+
var y = numeric(n[1])
|
|
175
|
+
var width = Math.max(n[0].length, n[1].length)
|
|
176
|
+
var incr =
|
|
177
|
+
n.length === 3 && n[2] !== undefined ?
|
|
178
|
+
Math.max(Math.abs(numeric(n[2])), 1)
|
|
179
|
+
: 1
|
|
180
|
+
var test = lte
|
|
181
|
+
var reverse = y < x
|
|
182
|
+
if (reverse) {
|
|
183
|
+
incr *= -1
|
|
184
|
+
test = gte
|
|
185
|
+
}
|
|
186
|
+
var pad = n.some(isPadded)
|
|
187
|
+
|
|
188
|
+
var length = 0
|
|
189
|
+
for (var i = x; test(i, y) && N.length < max; i += incr) {
|
|
190
|
+
var c
|
|
191
|
+
if (isAlphaSequence) {
|
|
192
|
+
c = String.fromCharCode(i)
|
|
193
|
+
if (c === '\\') {
|
|
194
|
+
c = ''
|
|
195
|
+
}
|
|
196
|
+
} else {
|
|
197
|
+
c = String(i)
|
|
198
|
+
if (pad) {
|
|
199
|
+
var need = width - c.length
|
|
200
|
+
if (need > 0) {
|
|
201
|
+
var z = new Array(need + 1).join('0')
|
|
202
|
+
if (i < 0) {
|
|
203
|
+
c = '-' + z + c.slice(1)
|
|
204
|
+
} else {
|
|
205
|
+
c = z + c
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (length + c.length > maxLength) break
|
|
211
|
+
N.push(c)
|
|
212
|
+
length += c.length
|
|
213
|
+
}
|
|
214
|
+
return N
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function expand(
|
|
218
|
+
str,
|
|
219
|
+
max,
|
|
220
|
+
maxLength,
|
|
221
|
+
isTop
|
|
222
|
+
) {
|
|
223
|
+
// Consume the string's top-level brace groups left to right, threading a
|
|
224
|
+
// running set of combined prefixes (`acc`). Expanding the tail iteratively -
|
|
225
|
+
// rather than recursing on `m.post` once per group - keeps the native stack
|
|
226
|
+
// depth constant, so deeply chained input (`'{a,b}'.repeat(3000)`) can no
|
|
227
|
+
// longer overflow the stack, and leaves a single accumulator whose size
|
|
228
|
+
// `maxLength` bounds directly (CVE-2026-14257).
|
|
229
|
+
var acc = ['']
|
|
230
|
+
|
|
231
|
+
// Bash drops empty results, but only when the *first* group of the run is a
|
|
232
|
+
// comma set - a sequence like `{a..\}` may legitimately yield ''. The drop
|
|
233
|
+
// is on the final strings, so it is applied to whichever `combine` produces
|
|
234
|
+
// them (the one with no brace set left in the tail).
|
|
235
|
+
//
|
|
236
|
+
// The old implementation recursed on `m.post`, so the drop tested only the
|
|
237
|
+
// expansion of the current call's substring. The `{a},b}` rewrite below turns
|
|
238
|
+
// `isTop` back on part-way through a string, starting a fresh such run, so
|
|
239
|
+
// the drop must ignore whatever `acc` already holds from earlier groups.
|
|
240
|
+
// `accBase[a]` records how much of `acc[a]` predates the current run;
|
|
241
|
+
// `combine` treats an expansion as empty when it adds nothing past that.
|
|
242
|
+
var accBase = [0]
|
|
243
|
+
var dropEmpties = false
|
|
244
|
+
var firstGroup = true
|
|
245
|
+
var nextBase
|
|
105
246
|
|
|
106
|
-
// The `{a},b}` rewrite below restarts expansion on a rewritten string with
|
|
107
|
-
// the same `max` and `isTop = true`. Loop instead of recursing so a long run
|
|
108
|
-
// of non-expanding `{}` groups can't exhaust the call stack.
|
|
109
247
|
for (;;) {
|
|
110
248
|
var m = balanced('{', '}', str);
|
|
111
|
-
|
|
249
|
+
|
|
250
|
+
// No brace set left: the rest of the string is literal.
|
|
251
|
+
if (!m) {
|
|
252
|
+
return combine(acc, accBase, str, [''], max, maxLength, dropEmpties, [])
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// no need to expand pre, since it is guaranteed to be free of brace-sets
|
|
256
|
+
var pre = m.pre;
|
|
257
|
+
|
|
258
|
+
// For compatibility reasons, `${` is not eligible for brace expansion, and
|
|
259
|
+
// on the 1.x line it suppresses expansion of the rest of the string too:
|
|
260
|
+
// the whole remainder is literal. The 2.x and 5.x lines instead keep
|
|
261
|
+
// expanding the tail, which is what bash does, but changing that here would
|
|
262
|
+
// be a breaking change for 1.x consumers. Routed through `combine` so the
|
|
263
|
+
// result is still bounded by `max` and `maxLength`.
|
|
264
|
+
if (/\$$/.test(pre)) {
|
|
265
|
+
return combine(acc, accBase, str, [''], max, maxLength, dropEmpties, [])
|
|
266
|
+
}
|
|
112
267
|
|
|
113
268
|
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
114
269
|
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
@@ -118,92 +273,110 @@ function expand(str, max, isTop) {
|
|
|
118
273
|
// {a},b}
|
|
119
274
|
if (m.post.match(/,(?!,).*\}/)) {
|
|
120
275
|
str = m.pre + '{' + m.body + escClose + m.post;
|
|
276
|
+
// The rewritten string is expanded as if it were a fresh top-level one,
|
|
277
|
+
// so start a new empty-drop run: anchor the baseline at what `acc`
|
|
278
|
+
// holds now, and let the next expanding group decide whether to drop.
|
|
121
279
|
isTop = true
|
|
280
|
+
firstGroup = true
|
|
281
|
+
dropEmpties = false
|
|
282
|
+
accBase = []
|
|
283
|
+
for (var b = 0; b < acc.length; b++) {
|
|
284
|
+
accBase.push(acc[b].length)
|
|
285
|
+
}
|
|
122
286
|
continue
|
|
123
287
|
}
|
|
124
|
-
|
|
288
|
+
// Nothing here expands, so the whole remaining string is literal.
|
|
289
|
+
return combine(
|
|
290
|
+
acc,
|
|
291
|
+
accBase,
|
|
292
|
+
pre + '{' + m.body + '}' + m.post,
|
|
293
|
+
[''],
|
|
294
|
+
max,
|
|
295
|
+
maxLength,
|
|
296
|
+
dropEmpties,
|
|
297
|
+
[]
|
|
298
|
+
)
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if (firstGroup) {
|
|
302
|
+
dropEmpties = isTop && !isSequence
|
|
303
|
+
firstGroup = false
|
|
125
304
|
}
|
|
126
305
|
|
|
127
|
-
var
|
|
306
|
+
var values;
|
|
128
307
|
if (isSequence) {
|
|
129
|
-
|
|
308
|
+
values = expandSequence(m.body, isAlphaSequence, max, maxLength);
|
|
130
309
|
} else {
|
|
131
|
-
n = parseCommaParts(m.body);
|
|
132
|
-
if (n.length === 1) {
|
|
310
|
+
var n = parseCommaParts(m.body);
|
|
311
|
+
if (n.length === 1 && n[0] !== undefined) {
|
|
133
312
|
// x{{a,b}}y ==> x{a}y x{b}y
|
|
134
|
-
n = expand(n[0], max, false).map(embrace);
|
|
313
|
+
n = expand(n[0], max, maxLength, false).map(embrace);
|
|
314
|
+
//XXX is this necessary? Can't seem to hit it in tests.
|
|
315
|
+
/* c8 ignore start */
|
|
135
316
|
if (n.length === 1) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
317
|
+
nextBase = []
|
|
318
|
+
acc = combine(
|
|
319
|
+
acc,
|
|
320
|
+
accBase,
|
|
321
|
+
pre + n[0],
|
|
322
|
+
[''],
|
|
323
|
+
max,
|
|
324
|
+
maxLength,
|
|
325
|
+
dropEmpties && !m.post.length,
|
|
326
|
+
nextBase
|
|
327
|
+
)
|
|
328
|
+
accBase = nextBase
|
|
329
|
+
if (!m.post.length) break
|
|
330
|
+
str = m.post
|
|
331
|
+
continue
|
|
142
332
|
}
|
|
333
|
+
/* c8 ignore stop */
|
|
143
334
|
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// at this point, n is the parts, and we know it's not a comma set
|
|
147
|
-
// with a single entry.
|
|
148
|
-
|
|
149
|
-
// no need to expand pre, since it is guaranteed to be free of brace-sets
|
|
150
|
-
var pre = m.pre;
|
|
151
|
-
var post = m.post.length
|
|
152
|
-
? expand(m.post, max, false)
|
|
153
|
-
: [''];
|
|
154
|
-
|
|
155
|
-
var N;
|
|
156
335
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
var
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
incr *= -1;
|
|
168
|
-
test = gte;
|
|
169
|
-
}
|
|
170
|
-
var pad = n.some(isPadded);
|
|
171
|
-
|
|
172
|
-
N = [];
|
|
173
|
-
|
|
174
|
-
for (var i = x; test(i, y) && N.length < max; i += incr) {
|
|
175
|
-
var c;
|
|
176
|
-
if (isAlphaSequence) {
|
|
177
|
-
c = String.fromCharCode(i);
|
|
178
|
-
if (c === '\\')
|
|
179
|
-
c = '';
|
|
180
|
-
} else {
|
|
181
|
-
c = String(i);
|
|
182
|
-
if (pad) {
|
|
183
|
-
var need = width - c.length;
|
|
184
|
-
if (need > 0) {
|
|
185
|
-
var z = new Array(need + 1).join('0');
|
|
186
|
-
if (i < 0)
|
|
187
|
-
c = '-' + z + c.slice(1);
|
|
188
|
-
else
|
|
189
|
-
c = z + c;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
336
|
+
// Values that `combine` is going to drop as empty produce no result, so
|
|
337
|
+
// they must not count against `max` - otherwise `{a,,b}` with `max: 2`
|
|
338
|
+
// would stop at `['a', '']` and yield one result instead of two. Skipping
|
|
339
|
+
// them outright keeps `values` bounded while leaving `max` a bound on
|
|
340
|
+
// *kept* results. A value is dropped when it adds nothing past the
|
|
341
|
+
// baseline, which is what `combine` tests.
|
|
342
|
+
var dropsEmpties = dropEmpties && !m.post.length && !pre
|
|
343
|
+
for (var d = 0; dropsEmpties && d < acc.length; d++) {
|
|
344
|
+
if (acc[d].length !== accBase[d]) {
|
|
345
|
+
dropsEmpties = false
|
|
192
346
|
}
|
|
193
|
-
N.push(c);
|
|
194
347
|
}
|
|
195
|
-
} else {
|
|
196
|
-
N = concatMap(n, function(el) { return expand(el, max, false) });
|
|
197
|
-
}
|
|
198
348
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
349
|
+
values = []
|
|
350
|
+
var valuesLength = 0
|
|
351
|
+
outer: for (var j = 0; j < n.length; j++) {
|
|
352
|
+
var expanded = expand(n[j], max, maxLength, false)
|
|
353
|
+
for (var k = 0; k < expanded.length; k++) {
|
|
354
|
+
var v = expanded[k]
|
|
355
|
+
if (dropsEmpties && !v) continue
|
|
356
|
+
if (values.length >= max || valuesLength + v.length > maxLength) {
|
|
357
|
+
break outer
|
|
358
|
+
}
|
|
359
|
+
values.push(v)
|
|
360
|
+
valuesLength += v.length
|
|
361
|
+
}
|
|
204
362
|
}
|
|
205
363
|
}
|
|
206
364
|
|
|
207
|
-
|
|
365
|
+
nextBase = []
|
|
366
|
+
acc = combine(
|
|
367
|
+
acc,
|
|
368
|
+
accBase,
|
|
369
|
+
pre,
|
|
370
|
+
values,
|
|
371
|
+
max,
|
|
372
|
+
maxLength,
|
|
373
|
+
dropEmpties && !m.post.length,
|
|
374
|
+
nextBase
|
|
375
|
+
)
|
|
376
|
+
accBase = nextBase
|
|
377
|
+
if (!m.post.length) break
|
|
378
|
+
str = m.post
|
|
208
379
|
}
|
|
380
|
+
|
|
381
|
+
return acc
|
|
209
382
|
}
|
|
@@ -51,11 +51,33 @@ expand('ppp{,config,oe{,conf}}')
|
|
|
51
51
|
var expand = require('brace-expansion');
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
### var expanded = expand(str)
|
|
54
|
+
### var expanded = expand(str, [options])
|
|
55
55
|
|
|
56
56
|
Return an array of all possible and valid expansions of `str`. If none are
|
|
57
57
|
found, `[str]` is returned.
|
|
58
58
|
|
|
59
|
+
The `options` object can provide a `max` value to cap the number
|
|
60
|
+
of expansions allowed. This is limited to `100_000` by default,
|
|
61
|
+
to prevent DoS attacks.
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
const expansions = expand('{1..100}'.repeat(5), {
|
|
65
|
+
max: 100,
|
|
66
|
+
})
|
|
67
|
+
// expansions.length will be 100, not 100^5
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The `options` object can also provide a `maxLength` value to cap the
|
|
71
|
+
total number of characters across all expansions. This is limited to
|
|
72
|
+
`4_000_000` by default, to prevent memory exhaustion from inputs whose
|
|
73
|
+
result count stays under `max` while each result grows very long.
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
const expansions = expand('{a,b}'.repeat(1500), {
|
|
77
|
+
maxLength: 10_000,
|
|
78
|
+
})
|
|
79
|
+
```
|
|
80
|
+
|
|
59
81
|
Valid expansions are:
|
|
60
82
|
|
|
61
83
|
```js
|