securemark 0.300.5 → 0.300.6
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/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.300.
|
|
1
|
+
/*! securemark v0.300.6 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
|
|
2
2
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
3
3
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
4
4
|
module.exports = factory(require("Prism"), require("DOMPurify"));
|
|
@@ -6460,10 +6460,10 @@ class RecursionCounter {
|
|
|
6460
6460
|
stack
|
|
6461
6461
|
} = this;
|
|
6462
6462
|
for (; this.index > 0 && stack[this.index - 1] >= depth; --this.index);
|
|
6463
|
-
// 内側から数えるので無効化処理できずエラーを投げるしかない。
|
|
6464
|
-
if (this.index === this.limit) return new Error(`Too much recursion`);
|
|
6465
6463
|
stack[this.index] = depth;
|
|
6466
6464
|
++this.index;
|
|
6465
|
+
// 内側から数えるので無効化処理できない。
|
|
6466
|
+
return this.index <= this.limit;
|
|
6467
6467
|
}
|
|
6468
6468
|
}
|
|
6469
6469
|
|
|
@@ -6740,8 +6740,13 @@ exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(1
|
|
|
6740
6740
|
class: (0, bracket_1.bracketname)(input, 1, 1)
|
|
6741
6741
|
}, (0, dom_1.defrag)((0, util_1.unwrap)(nodes))))]);
|
|
6742
6742
|
}
|
|
6743
|
-
output.error ??= recursion.add(resources?.recursions[2 /* Recursion.inline */] ?? resources?.recursions.at(-1));
|
|
6744
6743
|
input.position += 1;
|
|
6744
|
+
if (!recursion.add(resources?.recursions[2 /* Recursion.inline */] ?? resources?.recursions.at(-1))) {
|
|
6745
|
+
return new parser_1.List([new parser_1.Node((0, dom_1.html)('span', {
|
|
6746
|
+
class: 'invalid',
|
|
6747
|
+
...(0, util_1.invalid)('annotation', 'syntax', 'Recursions must be two or fewer')
|
|
6748
|
+
}, (0, dom_1.defrag)((0, util_1.unwrap)((0, visibility_1.trimBlankNodeEnd)(nodes)))))]);
|
|
6749
|
+
}
|
|
6745
6750
|
const el = (0, dom_1.html)('sup', {
|
|
6746
6751
|
class: 'annotation'
|
|
6747
6752
|
}, [(0, dom_1.html)('span', (0, dom_1.defrag)((0, util_1.unwrap)((0, visibility_1.trimBlankNodeEnd)(nodes))))]);
|
package/package.json
CHANGED
package/src/api/parse.test.ts
CHANGED
|
@@ -314,33 +314,6 @@ describe('Unit: api/parse', () => {
|
|
|
314
314
|
assert.deepStrictEqual(
|
|
315
315
|
[...run(parse(`${'{ '.repeat(101)}0`)).children].map(el => el.tagName),
|
|
316
316
|
['H1', 'PRE', 'OL']);
|
|
317
|
-
assert.deepStrictEqual(
|
|
318
|
-
[...run(parse(`${'(('.repeat(2)}0${'))'.repeat(2)}`)).children].map(el => el.tagName),
|
|
319
|
-
['P', 'OL', 'OL']);
|
|
320
|
-
assert.deepStrictEqual(
|
|
321
|
-
[...run(parse(`${'(('.repeat(3)}0${'))'.repeat(3)}`)).children].map(el => el.tagName),
|
|
322
|
-
['H1', 'PRE', 'OL']);
|
|
323
|
-
assert.deepStrictEqual(
|
|
324
|
-
[...run(parse(`(${'(('.repeat(2)}0${'))'.repeat(2)}`)).children].map(el => el.tagName),
|
|
325
|
-
['P', 'OL', 'OL']);
|
|
326
|
-
assert.deepStrictEqual(
|
|
327
|
-
[...run(parse(`(${'(('.repeat(3)}0${'))'.repeat(3)}`)).children].map(el => el.tagName),
|
|
328
|
-
['H1', 'PRE', 'OL']);
|
|
329
|
-
assert.deepStrictEqual(
|
|
330
|
-
[...run(parse(`${'(('.repeat(2)}0${'))'.repeat(2)}${'(('.repeat(2)}0${'))'.repeat(2)}`)).children].map(el => el.tagName),
|
|
331
|
-
['P', 'OL', 'OL']);
|
|
332
|
-
assert.deepStrictEqual(
|
|
333
|
-
[...run(parse(`${'(('.repeat(2)}0${'))'.repeat(2)}${'(('.repeat(3)}0${'))'.repeat(3)}`)).children].map(el => el.tagName),
|
|
334
|
-
['H1', 'PRE', 'OL']);
|
|
335
|
-
assert.deepStrictEqual(
|
|
336
|
-
[...run(parse(`${'(('.repeat(2)}0${'))'.repeat(2)}${'(('.repeat(9)}0${'))'.repeat(2)}`)).children].map(el => el.tagName),
|
|
337
|
-
['P', 'OL', 'OL']);
|
|
338
|
-
assert.deepStrictEqual(
|
|
339
|
-
[...run(parse(`${'(('.repeat(2)}0${'))'.repeat(2)}${'(('.repeat(9)}0${'))'.repeat(3)}`)).children].map(el => el.tagName),
|
|
340
|
-
['H1', 'PRE', 'OL']);
|
|
341
|
-
assert.deepStrictEqual(
|
|
342
|
-
[...run(parse(`${'(('.repeat(3)}0))((1))))))`)).children].map(el => el.tagName),
|
|
343
|
-
['H1', 'PRE', 'OL']);
|
|
344
317
|
});
|
|
345
318
|
|
|
346
319
|
it('recovery', () => {
|
package/src/parser/context.ts
CHANGED
|
@@ -79,13 +79,13 @@ class RecursionCounter {
|
|
|
79
79
|
}
|
|
80
80
|
private readonly stack: number[] = [];
|
|
81
81
|
private index = 0;
|
|
82
|
-
public add(depth: number):
|
|
82
|
+
public add(depth: number): boolean {
|
|
83
83
|
const { stack } = this
|
|
84
84
|
for (; this.index > 0 && stack[this.index - 1] >= depth; --this.index);
|
|
85
|
-
// 内側から数えるので無効化処理できずエラーを投げるしかない。
|
|
86
|
-
if (this.index === this.limit) return new Error(`Too much recursion`);
|
|
87
85
|
stack[this.index] = depth;
|
|
88
86
|
++this.index;
|
|
87
|
+
// 内側から数えるので無効化処理できない。
|
|
88
|
+
return this.index <= this.limit;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -62,6 +62,30 @@ describe('Unit: parser/inline/annotation', () => {
|
|
|
62
62
|
assert.deepStrictEqual(inspect(parser, input('(((a)))')), [['<sup class="annotation"><span><span class="paren">(a)</span></span></sup>'], '']);
|
|
63
63
|
assert.deepStrictEqual(inspect(parser, input('((((a))))')), [['<sup class="annotation"><span><sup class="annotation"><span>a</span></sup></span></sup>'], '']);
|
|
64
64
|
assert.deepStrictEqual(inspect(parser, input('(([[a]]))')), [['<sup class="annotation"><span><sup class="reference"><span>a</span></sup></span></sup>'], '']);
|
|
65
|
+
assert.deepStrictEqual(
|
|
66
|
+
inspect(parser, input(`${'(('.repeat(2)}0${'))'.repeat(2)}`)),
|
|
67
|
+
[['<sup class="annotation"><span><sup class="annotation"><span>0</span></sup></span></sup>'], '']);
|
|
68
|
+
assert.deepStrictEqual(
|
|
69
|
+
inspect(parser, input(`${'(('.repeat(3)}0${'))'.repeat(3)}`)),
|
|
70
|
+
[['<span class="invalid"><sup class="annotation"><span><sup class="annotation"><span>0</span></sup></span></sup></span>'], '']);
|
|
71
|
+
assert.deepStrictEqual(
|
|
72
|
+
inspect(parser, input(`(${'(('.repeat(2)}0${'))'.repeat(2)}`)),
|
|
73
|
+
[['<span class="paren">(<sup class="annotation"><span><sup class="annotation"><span>0</span></sup></span></sup></span>'], '']);
|
|
74
|
+
assert.deepStrictEqual(
|
|
75
|
+
inspect(parser, input(`(${'(('.repeat(3)}0${'))'.repeat(3)}`)),
|
|
76
|
+
[['<span class="paren">(<span class="invalid"><sup class="annotation"><span><sup class="annotation"><span>0</span></sup></span></sup></span></span>'], '']);
|
|
77
|
+
assert.deepStrictEqual(
|
|
78
|
+
inspect(parser, input(`${'(('.repeat(2)}0${'))'.repeat(2)}${'(('.repeat(2)}0${'))'.repeat(2)}`)),
|
|
79
|
+
[['<sup class="annotation"><span><sup class="annotation"><span>0</span></sup></span></sup>', '<sup class="annotation"><span><sup class="annotation"><span>0</span></sup></span></sup>'], '']);
|
|
80
|
+
assert.deepStrictEqual(
|
|
81
|
+
inspect(parser, input(`${'(('.repeat(2)}0${'))'.repeat(2)}${'(('.repeat(3)}0${'))'.repeat(2)}`)),
|
|
82
|
+
[['<sup class="annotation"><span><sup class="annotation"><span>0</span></sup></span></sup>', '<span class="paren">(<span class="paren">(<sup class="annotation"><span><sup class="annotation"><span>0</span></sup></span></sup></span></span>'], '']);
|
|
83
|
+
assert.deepStrictEqual(
|
|
84
|
+
inspect(parser, input(`${'(('.repeat(2)}0${'))'.repeat(2)}${'(('.repeat(3)}0${'))'.repeat(3)}`)),
|
|
85
|
+
[['<sup class="annotation"><span><sup class="annotation"><span>0</span></sup></span></sup>', '<span class="invalid"><sup class="annotation"><span><sup class="annotation"><span>0</span></sup></span></sup></span>'], '']);
|
|
86
|
+
assert.deepStrictEqual(
|
|
87
|
+
inspect(parser, input(`${'(('.repeat(3)}0))((1))))))`)),
|
|
88
|
+
[['<span class="invalid"><sup class="annotation"><span><sup class="annotation"><span>0</span></sup><sup class="annotation"><span>1</span></sup></span></sup></span>'], '']);
|
|
65
89
|
});
|
|
66
90
|
|
|
67
91
|
});
|
|
@@ -6,7 +6,7 @@ import { inline } from '../inline';
|
|
|
6
6
|
import { bracketname } from './bracket';
|
|
7
7
|
import { repeat } from '../repeat';
|
|
8
8
|
import { beforeNonblank, trimBlankNodeEnd } from '../visibility';
|
|
9
|
-
import { unwrap } from '../util';
|
|
9
|
+
import { unwrap, invalid } from '../util';
|
|
10
10
|
import { html, defrag } from 'typed-dom/dom';
|
|
11
11
|
|
|
12
12
|
// シグネチャ等生成のために構文木のツリーウォークを再帰的に行い指数計算量にならないよう
|
|
@@ -40,8 +40,15 @@ export const annotation: AnnotationParser = lazy(() => constraint(State.annotati
|
|
|
40
40
|
new Node(html('span', { class: bracketname(input, 1, 1) }, defrag(unwrap(nodes))))
|
|
41
41
|
]);
|
|
42
42
|
}
|
|
43
|
-
output.error ??= recursion.add(resources?.recursions[Recursion.inline] ?? resources?.recursions.at(-1));
|
|
44
43
|
input.position += 1;
|
|
44
|
+
if (!recursion.add(resources?.recursions[Recursion.inline] ?? resources?.recursions.at(-1))) {
|
|
45
|
+
return new List([new Node(html('span',
|
|
46
|
+
{
|
|
47
|
+
class: 'invalid',
|
|
48
|
+
...invalid('annotation', 'syntax', 'Recursions must be two or fewer')
|
|
49
|
+
},
|
|
50
|
+
defrag(unwrap(trimBlankNodeEnd(nodes)))))]);
|
|
51
|
+
}
|
|
45
52
|
const el = html('sup', { class: 'annotation' }, [
|
|
46
53
|
html('span', defrag(unwrap(trimBlankNodeEnd(nodes))))
|
|
47
54
|
]);
|