@gov-cy/govcy-frontend-renderer 1.26.7 → 1.26.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.
- package/dist/index.cjs +306 -0
- package/dist/index.mjs +306 -0
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -4677,6 +4677,8 @@ function requireConstants$2 () {
|
|
|
4677
4677
|
const WIN_SLASH = '\\\\/';
|
|
4678
4678
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
4679
4679
|
|
|
4680
|
+
const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
4681
|
+
|
|
4680
4682
|
/**
|
|
4681
4683
|
* Posix glob regex
|
|
4682
4684
|
*/
|
|
@@ -4740,6 +4742,7 @@ function requireConstants$2 () {
|
|
|
4740
4742
|
*/
|
|
4741
4743
|
|
|
4742
4744
|
const POSIX_REGEX_SOURCE = {
|
|
4745
|
+
__proto__: null,
|
|
4743
4746
|
alnum: 'a-zA-Z0-9',
|
|
4744
4747
|
alpha: 'a-zA-Z',
|
|
4745
4748
|
ascii: '\\x00-\\x7F',
|
|
@@ -4757,6 +4760,7 @@ function requireConstants$2 () {
|
|
|
4757
4760
|
};
|
|
4758
4761
|
|
|
4759
4762
|
constants$2 = {
|
|
4763
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
4760
4764
|
MAX_LENGTH: 1024 * 64,
|
|
4761
4765
|
POSIX_REGEX_SOURCE,
|
|
4762
4766
|
|
|
@@ -4770,6 +4774,7 @@ function requireConstants$2 () {
|
|
|
4770
4774
|
|
|
4771
4775
|
// Replace globs with equivalent patterns to reduce parsing time.
|
|
4772
4776
|
REPLACEMENTS: {
|
|
4777
|
+
__proto__: null,
|
|
4773
4778
|
'***': '*',
|
|
4774
4779
|
'**/**': '**',
|
|
4775
4780
|
'**/**/**': '**'
|
|
@@ -5377,6 +5382,277 @@ function requireParse$1 () {
|
|
|
5377
5382
|
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
5378
5383
|
};
|
|
5379
5384
|
|
|
5385
|
+
const splitTopLevel = input => {
|
|
5386
|
+
const parts = [];
|
|
5387
|
+
let bracket = 0;
|
|
5388
|
+
let paren = 0;
|
|
5389
|
+
let quote = 0;
|
|
5390
|
+
let value = '';
|
|
5391
|
+
let escaped = false;
|
|
5392
|
+
|
|
5393
|
+
for (const ch of input) {
|
|
5394
|
+
if (escaped === true) {
|
|
5395
|
+
value += ch;
|
|
5396
|
+
escaped = false;
|
|
5397
|
+
continue;
|
|
5398
|
+
}
|
|
5399
|
+
|
|
5400
|
+
if (ch === '\\') {
|
|
5401
|
+
value += ch;
|
|
5402
|
+
escaped = true;
|
|
5403
|
+
continue;
|
|
5404
|
+
}
|
|
5405
|
+
|
|
5406
|
+
if (ch === '"') {
|
|
5407
|
+
quote = quote === 1 ? 0 : 1;
|
|
5408
|
+
value += ch;
|
|
5409
|
+
continue;
|
|
5410
|
+
}
|
|
5411
|
+
|
|
5412
|
+
if (quote === 0) {
|
|
5413
|
+
if (ch === '[') {
|
|
5414
|
+
bracket++;
|
|
5415
|
+
} else if (ch === ']' && bracket > 0) {
|
|
5416
|
+
bracket--;
|
|
5417
|
+
} else if (bracket === 0) {
|
|
5418
|
+
if (ch === '(') {
|
|
5419
|
+
paren++;
|
|
5420
|
+
} else if (ch === ')' && paren > 0) {
|
|
5421
|
+
paren--;
|
|
5422
|
+
} else if (ch === '|' && paren === 0) {
|
|
5423
|
+
parts.push(value);
|
|
5424
|
+
value = '';
|
|
5425
|
+
continue;
|
|
5426
|
+
}
|
|
5427
|
+
}
|
|
5428
|
+
}
|
|
5429
|
+
|
|
5430
|
+
value += ch;
|
|
5431
|
+
}
|
|
5432
|
+
|
|
5433
|
+
parts.push(value);
|
|
5434
|
+
return parts;
|
|
5435
|
+
};
|
|
5436
|
+
|
|
5437
|
+
const isPlainBranch = branch => {
|
|
5438
|
+
let escaped = false;
|
|
5439
|
+
|
|
5440
|
+
for (const ch of branch) {
|
|
5441
|
+
if (escaped === true) {
|
|
5442
|
+
escaped = false;
|
|
5443
|
+
continue;
|
|
5444
|
+
}
|
|
5445
|
+
|
|
5446
|
+
if (ch === '\\') {
|
|
5447
|
+
escaped = true;
|
|
5448
|
+
continue;
|
|
5449
|
+
}
|
|
5450
|
+
|
|
5451
|
+
if (/[?*+@!()[\]{}]/.test(ch)) {
|
|
5452
|
+
return false;
|
|
5453
|
+
}
|
|
5454
|
+
}
|
|
5455
|
+
|
|
5456
|
+
return true;
|
|
5457
|
+
};
|
|
5458
|
+
|
|
5459
|
+
const normalizeSimpleBranch = branch => {
|
|
5460
|
+
let value = branch.trim();
|
|
5461
|
+
let changed = true;
|
|
5462
|
+
|
|
5463
|
+
while (changed === true) {
|
|
5464
|
+
changed = false;
|
|
5465
|
+
|
|
5466
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
5467
|
+
value = value.slice(2, -1);
|
|
5468
|
+
changed = true;
|
|
5469
|
+
}
|
|
5470
|
+
}
|
|
5471
|
+
|
|
5472
|
+
if (!isPlainBranch(value)) {
|
|
5473
|
+
return;
|
|
5474
|
+
}
|
|
5475
|
+
|
|
5476
|
+
return value.replace(/\\(.)/g, '$1');
|
|
5477
|
+
};
|
|
5478
|
+
|
|
5479
|
+
const hasRepeatedCharPrefixOverlap = branches => {
|
|
5480
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
5481
|
+
|
|
5482
|
+
for (let i = 0; i < values.length; i++) {
|
|
5483
|
+
for (let j = i + 1; j < values.length; j++) {
|
|
5484
|
+
const a = values[i];
|
|
5485
|
+
const b = values[j];
|
|
5486
|
+
const char = a[0];
|
|
5487
|
+
|
|
5488
|
+
if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
|
|
5489
|
+
continue;
|
|
5490
|
+
}
|
|
5491
|
+
|
|
5492
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) {
|
|
5493
|
+
return true;
|
|
5494
|
+
}
|
|
5495
|
+
}
|
|
5496
|
+
}
|
|
5497
|
+
|
|
5498
|
+
return false;
|
|
5499
|
+
};
|
|
5500
|
+
|
|
5501
|
+
const parseRepeatedExtglob = (pattern, requireEnd = true) => {
|
|
5502
|
+
if ((pattern[0] !== '+' && pattern[0] !== '*') || pattern[1] !== '(') {
|
|
5503
|
+
return;
|
|
5504
|
+
}
|
|
5505
|
+
|
|
5506
|
+
let bracket = 0;
|
|
5507
|
+
let paren = 0;
|
|
5508
|
+
let quote = 0;
|
|
5509
|
+
let escaped = false;
|
|
5510
|
+
|
|
5511
|
+
for (let i = 1; i < pattern.length; i++) {
|
|
5512
|
+
const ch = pattern[i];
|
|
5513
|
+
|
|
5514
|
+
if (escaped === true) {
|
|
5515
|
+
escaped = false;
|
|
5516
|
+
continue;
|
|
5517
|
+
}
|
|
5518
|
+
|
|
5519
|
+
if (ch === '\\') {
|
|
5520
|
+
escaped = true;
|
|
5521
|
+
continue;
|
|
5522
|
+
}
|
|
5523
|
+
|
|
5524
|
+
if (ch === '"') {
|
|
5525
|
+
quote = quote === 1 ? 0 : 1;
|
|
5526
|
+
continue;
|
|
5527
|
+
}
|
|
5528
|
+
|
|
5529
|
+
if (quote === 1) {
|
|
5530
|
+
continue;
|
|
5531
|
+
}
|
|
5532
|
+
|
|
5533
|
+
if (ch === '[') {
|
|
5534
|
+
bracket++;
|
|
5535
|
+
continue;
|
|
5536
|
+
}
|
|
5537
|
+
|
|
5538
|
+
if (ch === ']' && bracket > 0) {
|
|
5539
|
+
bracket--;
|
|
5540
|
+
continue;
|
|
5541
|
+
}
|
|
5542
|
+
|
|
5543
|
+
if (bracket > 0) {
|
|
5544
|
+
continue;
|
|
5545
|
+
}
|
|
5546
|
+
|
|
5547
|
+
if (ch === '(') {
|
|
5548
|
+
paren++;
|
|
5549
|
+
continue;
|
|
5550
|
+
}
|
|
5551
|
+
|
|
5552
|
+
if (ch === ')') {
|
|
5553
|
+
paren--;
|
|
5554
|
+
|
|
5555
|
+
if (paren === 0) {
|
|
5556
|
+
if (requireEnd === true && i !== pattern.length - 1) {
|
|
5557
|
+
return;
|
|
5558
|
+
}
|
|
5559
|
+
|
|
5560
|
+
return {
|
|
5561
|
+
type: pattern[0],
|
|
5562
|
+
body: pattern.slice(2, i),
|
|
5563
|
+
end: i
|
|
5564
|
+
};
|
|
5565
|
+
}
|
|
5566
|
+
}
|
|
5567
|
+
}
|
|
5568
|
+
};
|
|
5569
|
+
|
|
5570
|
+
const getStarExtglobSequenceOutput = pattern => {
|
|
5571
|
+
let index = 0;
|
|
5572
|
+
const chars = [];
|
|
5573
|
+
|
|
5574
|
+
while (index < pattern.length) {
|
|
5575
|
+
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
5576
|
+
|
|
5577
|
+
if (!match || match.type !== '*') {
|
|
5578
|
+
return;
|
|
5579
|
+
}
|
|
5580
|
+
|
|
5581
|
+
const branches = splitTopLevel(match.body).map(branch => branch.trim());
|
|
5582
|
+
if (branches.length !== 1) {
|
|
5583
|
+
return;
|
|
5584
|
+
}
|
|
5585
|
+
|
|
5586
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
5587
|
+
if (!branch || branch.length !== 1) {
|
|
5588
|
+
return;
|
|
5589
|
+
}
|
|
5590
|
+
|
|
5591
|
+
chars.push(branch);
|
|
5592
|
+
index += match.end + 1;
|
|
5593
|
+
}
|
|
5594
|
+
|
|
5595
|
+
if (chars.length < 1) {
|
|
5596
|
+
return;
|
|
5597
|
+
}
|
|
5598
|
+
|
|
5599
|
+
const source = chars.length === 1
|
|
5600
|
+
? utils.escapeRegex(chars[0])
|
|
5601
|
+
: `[${chars.map(ch => utils.escapeRegex(ch)).join('')}]`;
|
|
5602
|
+
|
|
5603
|
+
return `${source}*`;
|
|
5604
|
+
};
|
|
5605
|
+
|
|
5606
|
+
const repeatedExtglobRecursion = pattern => {
|
|
5607
|
+
let depth = 0;
|
|
5608
|
+
let value = pattern.trim();
|
|
5609
|
+
let match = parseRepeatedExtglob(value);
|
|
5610
|
+
|
|
5611
|
+
while (match) {
|
|
5612
|
+
depth++;
|
|
5613
|
+
value = match.body.trim();
|
|
5614
|
+
match = parseRepeatedExtglob(value);
|
|
5615
|
+
}
|
|
5616
|
+
|
|
5617
|
+
return depth;
|
|
5618
|
+
};
|
|
5619
|
+
|
|
5620
|
+
const analyzeRepeatedExtglob = (body, options) => {
|
|
5621
|
+
if (options.maxExtglobRecursion === false) {
|
|
5622
|
+
return { risky: false };
|
|
5623
|
+
}
|
|
5624
|
+
|
|
5625
|
+
const max =
|
|
5626
|
+
typeof options.maxExtglobRecursion === 'number'
|
|
5627
|
+
? options.maxExtglobRecursion
|
|
5628
|
+
: constants.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
5629
|
+
|
|
5630
|
+
const branches = splitTopLevel(body).map(branch => branch.trim());
|
|
5631
|
+
|
|
5632
|
+
if (branches.length > 1) {
|
|
5633
|
+
if (
|
|
5634
|
+
branches.some(branch => branch === '') ||
|
|
5635
|
+
branches.some(branch => /^[*?]+$/.test(branch)) ||
|
|
5636
|
+
hasRepeatedCharPrefixOverlap(branches)
|
|
5637
|
+
) {
|
|
5638
|
+
return { risky: true };
|
|
5639
|
+
}
|
|
5640
|
+
}
|
|
5641
|
+
|
|
5642
|
+
for (const branch of branches) {
|
|
5643
|
+
const safeOutput = getStarExtglobSequenceOutput(branch);
|
|
5644
|
+
if (safeOutput) {
|
|
5645
|
+
return { risky: true, safeOutput };
|
|
5646
|
+
}
|
|
5647
|
+
|
|
5648
|
+
if (repeatedExtglobRecursion(branch) > max) {
|
|
5649
|
+
return { risky: true };
|
|
5650
|
+
}
|
|
5651
|
+
}
|
|
5652
|
+
|
|
5653
|
+
return { risky: false };
|
|
5654
|
+
};
|
|
5655
|
+
|
|
5380
5656
|
/**
|
|
5381
5657
|
* Parse the given input string.
|
|
5382
5658
|
* @param {String} input
|
|
@@ -5558,6 +5834,8 @@ function requireParse$1 () {
|
|
|
5558
5834
|
token.prev = prev;
|
|
5559
5835
|
token.parens = state.parens;
|
|
5560
5836
|
token.output = state.output;
|
|
5837
|
+
token.startIndex = state.index;
|
|
5838
|
+
token.tokensIndex = tokens.length;
|
|
5561
5839
|
const output = (opts.capture ? '(' : '') + token.open;
|
|
5562
5840
|
|
|
5563
5841
|
increment('parens');
|
|
@@ -5567,6 +5845,34 @@ function requireParse$1 () {
|
|
|
5567
5845
|
};
|
|
5568
5846
|
|
|
5569
5847
|
const extglobClose = token => {
|
|
5848
|
+
const literal = input.slice(token.startIndex, state.index + 1);
|
|
5849
|
+
const body = input.slice(token.startIndex + 2, state.index);
|
|
5850
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
5851
|
+
|
|
5852
|
+
if ((token.type === 'plus' || token.type === 'star') && analysis.risky) {
|
|
5853
|
+
const safeOutput = analysis.safeOutput
|
|
5854
|
+
? (token.output ? '' : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput)
|
|
5855
|
+
: undefined;
|
|
5856
|
+
const open = tokens[token.tokensIndex];
|
|
5857
|
+
|
|
5858
|
+
open.type = 'text';
|
|
5859
|
+
open.value = literal;
|
|
5860
|
+
open.output = safeOutput || utils.escapeRegex(literal);
|
|
5861
|
+
|
|
5862
|
+
for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
|
|
5863
|
+
tokens[i].value = '';
|
|
5864
|
+
tokens[i].output = '';
|
|
5865
|
+
delete tokens[i].suffix;
|
|
5866
|
+
}
|
|
5867
|
+
|
|
5868
|
+
state.output = token.output + open.output;
|
|
5869
|
+
state.backtrack = true;
|
|
5870
|
+
|
|
5871
|
+
push({ type: 'paren', extglob: true, value, output: '' });
|
|
5872
|
+
decrement('parens');
|
|
5873
|
+
return;
|
|
5874
|
+
}
|
|
5875
|
+
|
|
5570
5876
|
let output = token.close + (opts.capture ? ')' : '');
|
|
5571
5877
|
let rest;
|
|
5572
5878
|
|
package/dist/index.mjs
CHANGED
|
@@ -4674,6 +4674,8 @@ function requireConstants$2 () {
|
|
|
4674
4674
|
const WIN_SLASH = '\\\\/';
|
|
4675
4675
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
4676
4676
|
|
|
4677
|
+
const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
4678
|
+
|
|
4677
4679
|
/**
|
|
4678
4680
|
* Posix glob regex
|
|
4679
4681
|
*/
|
|
@@ -4737,6 +4739,7 @@ function requireConstants$2 () {
|
|
|
4737
4739
|
*/
|
|
4738
4740
|
|
|
4739
4741
|
const POSIX_REGEX_SOURCE = {
|
|
4742
|
+
__proto__: null,
|
|
4740
4743
|
alnum: 'a-zA-Z0-9',
|
|
4741
4744
|
alpha: 'a-zA-Z',
|
|
4742
4745
|
ascii: '\\x00-\\x7F',
|
|
@@ -4754,6 +4757,7 @@ function requireConstants$2 () {
|
|
|
4754
4757
|
};
|
|
4755
4758
|
|
|
4756
4759
|
constants$2 = {
|
|
4760
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
4757
4761
|
MAX_LENGTH: 1024 * 64,
|
|
4758
4762
|
POSIX_REGEX_SOURCE,
|
|
4759
4763
|
|
|
@@ -4767,6 +4771,7 @@ function requireConstants$2 () {
|
|
|
4767
4771
|
|
|
4768
4772
|
// Replace globs with equivalent patterns to reduce parsing time.
|
|
4769
4773
|
REPLACEMENTS: {
|
|
4774
|
+
__proto__: null,
|
|
4770
4775
|
'***': '*',
|
|
4771
4776
|
'**/**': '**',
|
|
4772
4777
|
'**/**/**': '**'
|
|
@@ -5374,6 +5379,277 @@ function requireParse$1 () {
|
|
|
5374
5379
|
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
5375
5380
|
};
|
|
5376
5381
|
|
|
5382
|
+
const splitTopLevel = input => {
|
|
5383
|
+
const parts = [];
|
|
5384
|
+
let bracket = 0;
|
|
5385
|
+
let paren = 0;
|
|
5386
|
+
let quote = 0;
|
|
5387
|
+
let value = '';
|
|
5388
|
+
let escaped = false;
|
|
5389
|
+
|
|
5390
|
+
for (const ch of input) {
|
|
5391
|
+
if (escaped === true) {
|
|
5392
|
+
value += ch;
|
|
5393
|
+
escaped = false;
|
|
5394
|
+
continue;
|
|
5395
|
+
}
|
|
5396
|
+
|
|
5397
|
+
if (ch === '\\') {
|
|
5398
|
+
value += ch;
|
|
5399
|
+
escaped = true;
|
|
5400
|
+
continue;
|
|
5401
|
+
}
|
|
5402
|
+
|
|
5403
|
+
if (ch === '"') {
|
|
5404
|
+
quote = quote === 1 ? 0 : 1;
|
|
5405
|
+
value += ch;
|
|
5406
|
+
continue;
|
|
5407
|
+
}
|
|
5408
|
+
|
|
5409
|
+
if (quote === 0) {
|
|
5410
|
+
if (ch === '[') {
|
|
5411
|
+
bracket++;
|
|
5412
|
+
} else if (ch === ']' && bracket > 0) {
|
|
5413
|
+
bracket--;
|
|
5414
|
+
} else if (bracket === 0) {
|
|
5415
|
+
if (ch === '(') {
|
|
5416
|
+
paren++;
|
|
5417
|
+
} else if (ch === ')' && paren > 0) {
|
|
5418
|
+
paren--;
|
|
5419
|
+
} else if (ch === '|' && paren === 0) {
|
|
5420
|
+
parts.push(value);
|
|
5421
|
+
value = '';
|
|
5422
|
+
continue;
|
|
5423
|
+
}
|
|
5424
|
+
}
|
|
5425
|
+
}
|
|
5426
|
+
|
|
5427
|
+
value += ch;
|
|
5428
|
+
}
|
|
5429
|
+
|
|
5430
|
+
parts.push(value);
|
|
5431
|
+
return parts;
|
|
5432
|
+
};
|
|
5433
|
+
|
|
5434
|
+
const isPlainBranch = branch => {
|
|
5435
|
+
let escaped = false;
|
|
5436
|
+
|
|
5437
|
+
for (const ch of branch) {
|
|
5438
|
+
if (escaped === true) {
|
|
5439
|
+
escaped = false;
|
|
5440
|
+
continue;
|
|
5441
|
+
}
|
|
5442
|
+
|
|
5443
|
+
if (ch === '\\') {
|
|
5444
|
+
escaped = true;
|
|
5445
|
+
continue;
|
|
5446
|
+
}
|
|
5447
|
+
|
|
5448
|
+
if (/[?*+@!()[\]{}]/.test(ch)) {
|
|
5449
|
+
return false;
|
|
5450
|
+
}
|
|
5451
|
+
}
|
|
5452
|
+
|
|
5453
|
+
return true;
|
|
5454
|
+
};
|
|
5455
|
+
|
|
5456
|
+
const normalizeSimpleBranch = branch => {
|
|
5457
|
+
let value = branch.trim();
|
|
5458
|
+
let changed = true;
|
|
5459
|
+
|
|
5460
|
+
while (changed === true) {
|
|
5461
|
+
changed = false;
|
|
5462
|
+
|
|
5463
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
5464
|
+
value = value.slice(2, -1);
|
|
5465
|
+
changed = true;
|
|
5466
|
+
}
|
|
5467
|
+
}
|
|
5468
|
+
|
|
5469
|
+
if (!isPlainBranch(value)) {
|
|
5470
|
+
return;
|
|
5471
|
+
}
|
|
5472
|
+
|
|
5473
|
+
return value.replace(/\\(.)/g, '$1');
|
|
5474
|
+
};
|
|
5475
|
+
|
|
5476
|
+
const hasRepeatedCharPrefixOverlap = branches => {
|
|
5477
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
5478
|
+
|
|
5479
|
+
for (let i = 0; i < values.length; i++) {
|
|
5480
|
+
for (let j = i + 1; j < values.length; j++) {
|
|
5481
|
+
const a = values[i];
|
|
5482
|
+
const b = values[j];
|
|
5483
|
+
const char = a[0];
|
|
5484
|
+
|
|
5485
|
+
if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
|
|
5486
|
+
continue;
|
|
5487
|
+
}
|
|
5488
|
+
|
|
5489
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) {
|
|
5490
|
+
return true;
|
|
5491
|
+
}
|
|
5492
|
+
}
|
|
5493
|
+
}
|
|
5494
|
+
|
|
5495
|
+
return false;
|
|
5496
|
+
};
|
|
5497
|
+
|
|
5498
|
+
const parseRepeatedExtglob = (pattern, requireEnd = true) => {
|
|
5499
|
+
if ((pattern[0] !== '+' && pattern[0] !== '*') || pattern[1] !== '(') {
|
|
5500
|
+
return;
|
|
5501
|
+
}
|
|
5502
|
+
|
|
5503
|
+
let bracket = 0;
|
|
5504
|
+
let paren = 0;
|
|
5505
|
+
let quote = 0;
|
|
5506
|
+
let escaped = false;
|
|
5507
|
+
|
|
5508
|
+
for (let i = 1; i < pattern.length; i++) {
|
|
5509
|
+
const ch = pattern[i];
|
|
5510
|
+
|
|
5511
|
+
if (escaped === true) {
|
|
5512
|
+
escaped = false;
|
|
5513
|
+
continue;
|
|
5514
|
+
}
|
|
5515
|
+
|
|
5516
|
+
if (ch === '\\') {
|
|
5517
|
+
escaped = true;
|
|
5518
|
+
continue;
|
|
5519
|
+
}
|
|
5520
|
+
|
|
5521
|
+
if (ch === '"') {
|
|
5522
|
+
quote = quote === 1 ? 0 : 1;
|
|
5523
|
+
continue;
|
|
5524
|
+
}
|
|
5525
|
+
|
|
5526
|
+
if (quote === 1) {
|
|
5527
|
+
continue;
|
|
5528
|
+
}
|
|
5529
|
+
|
|
5530
|
+
if (ch === '[') {
|
|
5531
|
+
bracket++;
|
|
5532
|
+
continue;
|
|
5533
|
+
}
|
|
5534
|
+
|
|
5535
|
+
if (ch === ']' && bracket > 0) {
|
|
5536
|
+
bracket--;
|
|
5537
|
+
continue;
|
|
5538
|
+
}
|
|
5539
|
+
|
|
5540
|
+
if (bracket > 0) {
|
|
5541
|
+
continue;
|
|
5542
|
+
}
|
|
5543
|
+
|
|
5544
|
+
if (ch === '(') {
|
|
5545
|
+
paren++;
|
|
5546
|
+
continue;
|
|
5547
|
+
}
|
|
5548
|
+
|
|
5549
|
+
if (ch === ')') {
|
|
5550
|
+
paren--;
|
|
5551
|
+
|
|
5552
|
+
if (paren === 0) {
|
|
5553
|
+
if (requireEnd === true && i !== pattern.length - 1) {
|
|
5554
|
+
return;
|
|
5555
|
+
}
|
|
5556
|
+
|
|
5557
|
+
return {
|
|
5558
|
+
type: pattern[0],
|
|
5559
|
+
body: pattern.slice(2, i),
|
|
5560
|
+
end: i
|
|
5561
|
+
};
|
|
5562
|
+
}
|
|
5563
|
+
}
|
|
5564
|
+
}
|
|
5565
|
+
};
|
|
5566
|
+
|
|
5567
|
+
const getStarExtglobSequenceOutput = pattern => {
|
|
5568
|
+
let index = 0;
|
|
5569
|
+
const chars = [];
|
|
5570
|
+
|
|
5571
|
+
while (index < pattern.length) {
|
|
5572
|
+
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
5573
|
+
|
|
5574
|
+
if (!match || match.type !== '*') {
|
|
5575
|
+
return;
|
|
5576
|
+
}
|
|
5577
|
+
|
|
5578
|
+
const branches = splitTopLevel(match.body).map(branch => branch.trim());
|
|
5579
|
+
if (branches.length !== 1) {
|
|
5580
|
+
return;
|
|
5581
|
+
}
|
|
5582
|
+
|
|
5583
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
5584
|
+
if (!branch || branch.length !== 1) {
|
|
5585
|
+
return;
|
|
5586
|
+
}
|
|
5587
|
+
|
|
5588
|
+
chars.push(branch);
|
|
5589
|
+
index += match.end + 1;
|
|
5590
|
+
}
|
|
5591
|
+
|
|
5592
|
+
if (chars.length < 1) {
|
|
5593
|
+
return;
|
|
5594
|
+
}
|
|
5595
|
+
|
|
5596
|
+
const source = chars.length === 1
|
|
5597
|
+
? utils.escapeRegex(chars[0])
|
|
5598
|
+
: `[${chars.map(ch => utils.escapeRegex(ch)).join('')}]`;
|
|
5599
|
+
|
|
5600
|
+
return `${source}*`;
|
|
5601
|
+
};
|
|
5602
|
+
|
|
5603
|
+
const repeatedExtglobRecursion = pattern => {
|
|
5604
|
+
let depth = 0;
|
|
5605
|
+
let value = pattern.trim();
|
|
5606
|
+
let match = parseRepeatedExtglob(value);
|
|
5607
|
+
|
|
5608
|
+
while (match) {
|
|
5609
|
+
depth++;
|
|
5610
|
+
value = match.body.trim();
|
|
5611
|
+
match = parseRepeatedExtglob(value);
|
|
5612
|
+
}
|
|
5613
|
+
|
|
5614
|
+
return depth;
|
|
5615
|
+
};
|
|
5616
|
+
|
|
5617
|
+
const analyzeRepeatedExtglob = (body, options) => {
|
|
5618
|
+
if (options.maxExtglobRecursion === false) {
|
|
5619
|
+
return { risky: false };
|
|
5620
|
+
}
|
|
5621
|
+
|
|
5622
|
+
const max =
|
|
5623
|
+
typeof options.maxExtglobRecursion === 'number'
|
|
5624
|
+
? options.maxExtglobRecursion
|
|
5625
|
+
: constants.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
5626
|
+
|
|
5627
|
+
const branches = splitTopLevel(body).map(branch => branch.trim());
|
|
5628
|
+
|
|
5629
|
+
if (branches.length > 1) {
|
|
5630
|
+
if (
|
|
5631
|
+
branches.some(branch => branch === '') ||
|
|
5632
|
+
branches.some(branch => /^[*?]+$/.test(branch)) ||
|
|
5633
|
+
hasRepeatedCharPrefixOverlap(branches)
|
|
5634
|
+
) {
|
|
5635
|
+
return { risky: true };
|
|
5636
|
+
}
|
|
5637
|
+
}
|
|
5638
|
+
|
|
5639
|
+
for (const branch of branches) {
|
|
5640
|
+
const safeOutput = getStarExtglobSequenceOutput(branch);
|
|
5641
|
+
if (safeOutput) {
|
|
5642
|
+
return { risky: true, safeOutput };
|
|
5643
|
+
}
|
|
5644
|
+
|
|
5645
|
+
if (repeatedExtglobRecursion(branch) > max) {
|
|
5646
|
+
return { risky: true };
|
|
5647
|
+
}
|
|
5648
|
+
}
|
|
5649
|
+
|
|
5650
|
+
return { risky: false };
|
|
5651
|
+
};
|
|
5652
|
+
|
|
5377
5653
|
/**
|
|
5378
5654
|
* Parse the given input string.
|
|
5379
5655
|
* @param {String} input
|
|
@@ -5555,6 +5831,8 @@ function requireParse$1 () {
|
|
|
5555
5831
|
token.prev = prev;
|
|
5556
5832
|
token.parens = state.parens;
|
|
5557
5833
|
token.output = state.output;
|
|
5834
|
+
token.startIndex = state.index;
|
|
5835
|
+
token.tokensIndex = tokens.length;
|
|
5558
5836
|
const output = (opts.capture ? '(' : '') + token.open;
|
|
5559
5837
|
|
|
5560
5838
|
increment('parens');
|
|
@@ -5564,6 +5842,34 @@ function requireParse$1 () {
|
|
|
5564
5842
|
};
|
|
5565
5843
|
|
|
5566
5844
|
const extglobClose = token => {
|
|
5845
|
+
const literal = input.slice(token.startIndex, state.index + 1);
|
|
5846
|
+
const body = input.slice(token.startIndex + 2, state.index);
|
|
5847
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
5848
|
+
|
|
5849
|
+
if ((token.type === 'plus' || token.type === 'star') && analysis.risky) {
|
|
5850
|
+
const safeOutput = analysis.safeOutput
|
|
5851
|
+
? (token.output ? '' : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput)
|
|
5852
|
+
: undefined;
|
|
5853
|
+
const open = tokens[token.tokensIndex];
|
|
5854
|
+
|
|
5855
|
+
open.type = 'text';
|
|
5856
|
+
open.value = literal;
|
|
5857
|
+
open.output = safeOutput || utils.escapeRegex(literal);
|
|
5858
|
+
|
|
5859
|
+
for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
|
|
5860
|
+
tokens[i].value = '';
|
|
5861
|
+
tokens[i].output = '';
|
|
5862
|
+
delete tokens[i].suffix;
|
|
5863
|
+
}
|
|
5864
|
+
|
|
5865
|
+
state.output = token.output + open.output;
|
|
5866
|
+
state.backtrack = true;
|
|
5867
|
+
|
|
5868
|
+
push({ type: 'paren', extglob: true, value, output: '' });
|
|
5869
|
+
decrement('parens');
|
|
5870
|
+
return;
|
|
5871
|
+
}
|
|
5872
|
+
|
|
5567
5873
|
let output = token.close + (opts.capture ? ')' : '');
|
|
5568
5874
|
let rest;
|
|
5569
5875
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gov-cy/govcy-frontend-renderer",
|
|
3
|
-
"version": "1.26.
|
|
3
|
+
"version": "1.26.9",
|
|
4
4
|
"description": "Render html for design elements of the Unified design system using njk or json template.",
|
|
5
5
|
"author": "DMRID - DSF Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"overrides": {
|
|
57
57
|
"tar-fs": "^3.1.1",
|
|
58
58
|
"minimatch": "^10.2.1",
|
|
59
|
-
"serialize-javascript": "^7.0.3"
|
|
59
|
+
"serialize-javascript": "^7.0.3",
|
|
60
|
+
"yauzl": "^3.2.1"
|
|
60
61
|
}
|
|
61
62
|
}
|