securemark 0.253.1 → 0.253.2
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/.eslintrc.json +7 -1
- package/CHANGELOG.md +4 -0
- package/dist/index.js +6 -5
- package/markdown.d.ts +2 -1
- package/package.json +3 -3
- package/src/parser/block/extension/table.ts +6 -2
- package/src/parser/inline/html.test.ts +9 -6
- package/src/parser/inline/html.ts +11 -13
package/.eslintrc.json
CHANGED
|
@@ -15,8 +15,14 @@
|
|
|
15
15
|
"error",
|
|
16
16
|
{
|
|
17
17
|
"ignoreErrors": false,
|
|
18
|
+
"maxPatternSize": 3000,
|
|
19
|
+
"maxRepeatCount": 256,
|
|
20
|
+
"maxSimpleRepeatCount": 256,
|
|
18
21
|
"attackTimeout": null,
|
|
19
|
-
"
|
|
22
|
+
"incubationTimeout": null,
|
|
23
|
+
"recallTimeout": null,
|
|
24
|
+
"seedingTimeout": null,
|
|
25
|
+
"timeout": 1e6
|
|
20
26
|
}
|
|
21
27
|
]
|
|
22
28
|
},
|
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.253.
|
|
1
|
+
/*! securemark v0.253.2 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("DOMPurify"), require("Prism"));
|
|
@@ -4545,8 +4545,8 @@ function format(rows) {
|
|
|
4545
4545
|
|
|
4546
4546
|
if (colSpan > 1) {
|
|
4547
4547
|
(0, array_1.splice)(cells, j + 1, 0, ...(0, global_1.Array)(colSpan - 1));
|
|
4548
|
-
heads |=
|
|
4549
|
-
highlights |=
|
|
4548
|
+
heads |= heads & 1n << jn ? ~(~0n << (0, global_1.BigInt)(colSpan)) << jn : 0n;
|
|
4549
|
+
highlights |= highlights & 1n << jn ? ~(~0n << (0, global_1.BigInt)(colSpan)) << jn : 0n;
|
|
4550
4550
|
j += colSpan - 1;
|
|
4551
4551
|
}
|
|
4552
4552
|
|
|
@@ -6209,7 +6209,7 @@ const cache_1 = __webpack_require__(9210);
|
|
|
6209
6209
|
|
|
6210
6210
|
const array_1 = __webpack_require__(8112);
|
|
6211
6211
|
|
|
6212
|
-
const tags = global_1.Object.freeze(['
|
|
6212
|
+
const tags = global_1.Object.freeze(['sup', 'sub', 'small', 'bdo', 'bdi']);
|
|
6213
6213
|
const attrspec = {
|
|
6214
6214
|
bdo: {
|
|
6215
6215
|
dir: global_1.Object.freeze(['ltr', 'rtl'])
|
|
@@ -6217,7 +6217,8 @@ const attrspec = {
|
|
|
6217
6217
|
};
|
|
6218
6218
|
global_1.Object.setPrototypeOf(attrspec, null);
|
|
6219
6219
|
global_1.Object.values(attrspec).forEach(o => global_1.Object.setPrototypeOf(o, null));
|
|
6220
|
-
exports.html = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.validate)('<', (0, combinator_1.validate)(/^<[a-z]+(?=[^\S\n]|>)/, (0, combinator_1.union)([(0, combinator_1.
|
|
6220
|
+
exports.html = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.validate)('<', (0, combinator_1.validate)(/^<[a-z]+(?=[^\S\n]|>)/, (0, combinator_1.union)([(0, combinator_1.focus)('<wbr>', () => [[(0, dom_1.html)('wbr')], '']), (0, combinator_1.focus)( // https://html.spec.whatwg.org/multipage/syntax.html#void-elements
|
|
6221
|
+
/^<(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)(?=[^\S\n]|>)/, source => [[source], '']), (0, combinator_1.match)(/^<(sup|sub|small|bdo|bdi)(?=[^\S\n]|>)/, (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.surround)((0, combinator_1.surround)((0, source_1.str)(`<${tag}`), (0, combinator_1.some)(exports.attribute), (0, source_1.str)(/^[^\S\n]*>/), true), (0, util_1.startLoose)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.open)(/^\n?/, (0, combinator_1.some)(inline_1.inline, (0, util_1.blankWith)('\n', `</${tag}>`)), true)])), `</${tag}>`), (0, source_1.str)(`</${tag}>`), false, ([as, bs, cs], rest) => [[elem(tag, as, bs, cs)], rest]), ([, tag]) => tags.indexOf(tag), [])), (0, combinator_1.match)(/^<([a-z]+)(?=[^\S\n]|>)/, (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.surround)((0, combinator_1.surround)((0, source_1.str)(`<${tag}`), (0, combinator_1.some)(exports.attribute), (0, source_1.str)(/^[^\S\n]*>/), true), (0, util_1.startLoose)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.open)(/^\n?/, (0, combinator_1.some)(inline_1.inline, (0, util_1.blankWith)('\n', `</${tag}>`)), true)])), `</${tag}>`), (0, source_1.str)(`</${tag}>`), false, ([as, bs, cs], rest) => [[elem(tag, as, bs, cs)], rest]), ([, tag]) => tag, new cache_1.Cache(10000)))])))));
|
|
6221
6222
|
exports.attribute = (0, combinator_1.union)([(0, source_1.str)(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[^\S\n]|>)/)]);
|
|
6222
6223
|
|
|
6223
6224
|
function elem(tag, as, bs, cs) {
|
package/markdown.d.ts
CHANGED
|
@@ -964,11 +964,12 @@ export namespace MarkdownParser {
|
|
|
964
964
|
}
|
|
965
965
|
}
|
|
966
966
|
export interface HTMLParser extends
|
|
967
|
-
// Allow: sup, sub, small, bdo, bdi
|
|
967
|
+
// Allow: wbr, sup, sub, small, bdo, bdi
|
|
968
968
|
// <small>abc</small>
|
|
969
969
|
Inline<'html'>,
|
|
970
970
|
Parser<HTMLElement | string, Context, [
|
|
971
971
|
HTMLParser.OpenTagParser,
|
|
972
|
+
SourceParser.StrParser,
|
|
972
973
|
HTMLParser.TagParser,
|
|
973
974
|
HTMLParser.TagParser,
|
|
974
975
|
]> {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "securemark",
|
|
3
|
-
"version": "0.253.
|
|
3
|
+
"version": "0.253.2",
|
|
4
4
|
"description": "Secure markdown renderer working on browsers for user input data.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/falsandtru/securemark",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"babel-plugin-unassert": "^3.2.0",
|
|
40
40
|
"concurrently": "^7.2.2",
|
|
41
41
|
"eslint": "^8.17.0",
|
|
42
|
-
"eslint-plugin-redos": "^4.4.
|
|
42
|
+
"eslint-plugin-redos": "^4.4.1",
|
|
43
43
|
"eslint-webpack-plugin": "^3.1.1",
|
|
44
44
|
"glob": "^8.0.3",
|
|
45
45
|
"karma": "^6.4.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"karma-mocha": "^2.0.1",
|
|
50
50
|
"karma-power-assert": "^1.0.0",
|
|
51
51
|
"mocha": "^10.0.0",
|
|
52
|
-
"npm-check-updates": "^
|
|
52
|
+
"npm-check-updates": "^14.0.1",
|
|
53
53
|
"semver": "^7.3.7",
|
|
54
54
|
"spica": "0.0.570",
|
|
55
55
|
"ts-loader": "^9.3.0",
|
|
@@ -248,8 +248,12 @@ function format(rows: Tree<RowParser>[]): HTMLTableSectionElement[] {
|
|
|
248
248
|
assert(colSpan > 0);
|
|
249
249
|
if (colSpan > 1) {
|
|
250
250
|
splice(cells, j + 1, 0, ...Array(colSpan - 1));
|
|
251
|
-
heads |=
|
|
252
|
-
|
|
251
|
+
heads |= heads & 1n << jn
|
|
252
|
+
? ~(~0n << BigInt(colSpan)) << jn
|
|
253
|
+
: 0n;
|
|
254
|
+
highlights |= highlights & 1n << jn
|
|
255
|
+
? ~(~0n << BigInt(colSpan)) << jn
|
|
256
|
+
: 0n;
|
|
253
257
|
j += colSpan - 1;
|
|
254
258
|
}
|
|
255
259
|
if (target === thead) {
|
|
@@ -16,7 +16,6 @@ describe('Unit: parser/inline/html', () => {
|
|
|
16
16
|
assert.deepStrictEqual(inspect(parser('<small onclick="alert()">a</small>')), [['<span class="invalid"><small onclick="alert()">a</small></span>'], '']);
|
|
17
17
|
assert.deepStrictEqual(inspect(parser('<small><small onclick="alert()">a</small></small>')), [['<small><span class="invalid"><small onclick="alert()">a</small></span></small>'], '']);
|
|
18
18
|
assert.deepStrictEqual(inspect(parser('<bdo dir="rtl\\"><">a</bdo>')), [['<span class="invalid"><bdo dir="rtl\\"><">a</bdo></span>'], '']);
|
|
19
|
-
assert.deepStrictEqual(inspect(parser('<wbr onclick="alert()">')), [['<wbr class="invalid">'], '']);
|
|
20
19
|
});
|
|
21
20
|
|
|
22
21
|
it('invalid', () => {
|
|
@@ -84,14 +83,16 @@ describe('Unit: parser/inline/html', () => {
|
|
|
84
83
|
assert.deepStrictEqual(inspect(parser('<a>')), undefined);
|
|
85
84
|
assert.deepStrictEqual(inspect(parser('<small><a>a</a></small>')), [['<small><span class="invalid"><a>a</a></span></small>'], '']);
|
|
86
85
|
assert.deepStrictEqual(inspect(parser('<small>a<a>b</a>c</small>')), [['<small>a<span class="invalid"><a>b</a></span>c</small>'], '']);
|
|
87
|
-
assert.deepStrictEqual(inspect(parser('<img>')),
|
|
86
|
+
assert.deepStrictEqual(inspect(parser('<img>')), [['<img'], '>']);
|
|
88
87
|
assert.deepStrictEqual(inspect(parser('<small><img></small>')), [['<small><img></small>'], '']);
|
|
89
|
-
assert.deepStrictEqual(inspect(parser('<img />')),
|
|
88
|
+
assert.deepStrictEqual(inspect(parser('<img />')), [['<img'], ' />']);
|
|
90
89
|
assert.deepStrictEqual(inspect(parser('<small><img /></small>')), [['<small><img /></small>'], '']);
|
|
91
90
|
});
|
|
92
91
|
|
|
93
92
|
it('attribute', () => {
|
|
93
|
+
assert.deepStrictEqual(inspect(parser('<small\n>a</small>')), undefined);
|
|
94
94
|
assert.deepStrictEqual(inspect(parser('<small >a</small>')), [['<small>a</small>'], '']);
|
|
95
|
+
assert.deepStrictEqual(inspect(parser('<small \n>a</small>')), undefined);
|
|
95
96
|
assert.deepStrictEqual(inspect(parser('<small >a</small>')), [['<small>a</small>'], '']);
|
|
96
97
|
assert.deepStrictEqual(inspect(parser('<small __proto__>a</small>')), undefined);
|
|
97
98
|
assert.deepStrictEqual(inspect(parser('<small constructor>a</small>')), [['<span class="invalid"><small constructor>a</small></span>'], '']);
|
|
@@ -116,9 +117,11 @@ describe('Unit: parser/inline/html', () => {
|
|
|
116
117
|
assert.deepStrictEqual(inspect(parser('<bdo dir="rtl" >a</bdo>')), [['<bdo dir="rtl">a</bdo>'], '']);
|
|
117
118
|
assert.deepStrictEqual(inspect(parser('<bdo dir="rtl" >a</bdo>')), [['<bdo dir="rtl">a</bdo>'], '']);
|
|
118
119
|
assert.deepStrictEqual(inspect(parser('<bdo dir="rtl">a</bdo>')), [['<bdo dir="rtl">a</bdo>'], '']);
|
|
119
|
-
assert.deepStrictEqual(inspect(parser('<wbr
|
|
120
|
-
assert.deepStrictEqual(inspect(parser('<wbr
|
|
121
|
-
assert.deepStrictEqual(inspect(parser('<wbr
|
|
120
|
+
assert.deepStrictEqual(inspect(parser('<wbr\n>')), undefined);
|
|
121
|
+
assert.deepStrictEqual(inspect(parser('<wbr >')), [['<wbr'], ' >']);
|
|
122
|
+
assert.deepStrictEqual(inspect(parser('<wbr constructor>')), [['<wbr'], ' constructor>']);
|
|
123
|
+
assert.deepStrictEqual(inspect(parser('<wbr X>')), [['<wbr'], ' X>']);
|
|
124
|
+
assert.deepStrictEqual(inspect(parser('<wbr x>')), [['<wbr'], ' x>']);
|
|
122
125
|
});
|
|
123
126
|
|
|
124
127
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { undefined, Object } from 'spica/global';
|
|
2
2
|
import { HTMLParser } from '../inline';
|
|
3
|
-
import { union, some, validate, creator, surround, open, match, lazy } from '../../combinator';
|
|
3
|
+
import { union, some, validate, focus, creator, surround, open, match, lazy } from '../../combinator';
|
|
4
4
|
import { inline } from '../inline';
|
|
5
5
|
import { str } from '../source';
|
|
6
6
|
import { startLoose, blankWith } from '../util';
|
|
@@ -9,7 +9,7 @@ import { memoize } from 'spica/memoize';
|
|
|
9
9
|
import { Cache } from 'spica/cache';
|
|
10
10
|
import { unshift, push, splice } from 'spica/array';
|
|
11
11
|
|
|
12
|
-
const tags = Object.freeze(['
|
|
12
|
+
const tags = Object.freeze(['sup', 'sub', 'small', 'bdo', 'bdi']);
|
|
13
13
|
const attrspec = {
|
|
14
14
|
bdo: {
|
|
15
15
|
dir: Object.freeze(['ltr', 'rtl'] as const),
|
|
@@ -19,21 +19,19 @@ Object.setPrototypeOf(attrspec, null);
|
|
|
19
19
|
Object.values(attrspec).forEach(o => Object.setPrototypeOf(o, null));
|
|
20
20
|
|
|
21
21
|
export const html: HTMLParser = lazy(() => creator(validate('<', validate(/^<[a-z]+(?=[^\S\n]|>)/, union([
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
[[h(tag as 'span', attributes('html', [], attrspec[tag], bs))], rest]),
|
|
30
|
-
([, tag]) => tags.indexOf(tag), [])),
|
|
22
|
+
focus(
|
|
23
|
+
'<wbr>',
|
|
24
|
+
() => [[h('wbr')], '']),
|
|
25
|
+
focus(
|
|
26
|
+
// https://html.spec.whatwg.org/multipage/syntax.html#void-elements
|
|
27
|
+
/^<(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)(?=[^\S\n]|>)/,
|
|
28
|
+
source => [[source], '']),
|
|
31
29
|
match(
|
|
32
30
|
/^<(sup|sub|small|bdo|bdi)(?=[^\S\n]|>)/,
|
|
33
31
|
memoize(
|
|
34
32
|
([, tag]) =>
|
|
35
33
|
surround<HTMLParser.TagParser, string>(surround(
|
|
36
|
-
str(`<${tag}`), some(attribute), str(
|
|
34
|
+
str(`<${tag}`), some(attribute), str(/^[^\S\n]*>/), true),
|
|
37
35
|
startLoose(some(union([
|
|
38
36
|
open(/^\n?/, some(inline, blankWith('\n', `</${tag}>`)), true),
|
|
39
37
|
])), `</${tag}>`),
|
|
@@ -46,7 +44,7 @@ export const html: HTMLParser = lazy(() => creator(validate('<', validate(/^<[a-
|
|
|
46
44
|
memoize(
|
|
47
45
|
([, tag]) =>
|
|
48
46
|
surround<HTMLParser.TagParser, string>(surround(
|
|
49
|
-
str(`<${tag}`), some(attribute), str(
|
|
47
|
+
str(`<${tag}`), some(attribute), str(/^[^\S\n]*>/), true),
|
|
50
48
|
startLoose(some(union([
|
|
51
49
|
open(/^\n?/, some(inline, blankWith('\n', `</${tag}>`)), true),
|
|
52
50
|
])), `</${tag}>`),
|