@waline/vercel 1.31.2 → 1.31.4
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/__tests__/__snapshots__/mathjax.spec.js.snap +16 -0
- package/__tests__/__snapshots__/xss.spec.js.snap +1 -1
- package/__tests__/katex.spec.js +17 -17
- package/__tests__/mathjax.spec.js +31 -35
- package/__tests__/xss.spec.js +17 -17
- package/package.json +11 -11
- package/src/config/netlify.js +1 -1
- package/src/controller/article.js +4 -3
- package/src/controller/comment.js +36 -33
- package/src/controller/db.js +3 -3
- package/src/controller/oauth.js +4 -4
- package/src/controller/token/2fa.js +1 -1
- package/src/controller/user/password.js +1 -1
- package/src/controller/user.js +8 -8
- package/src/extend/think.js +2 -2
- package/src/logic/base.js +5 -5
- package/src/middleware/prefix-warning.js +1 -1
- package/src/service/akismet.js +1 -1
- package/src/service/markdown/katex.js +7 -7
- package/src/service/markdown/mathCommon.js +6 -6
- package/src/service/markdown/mathjax.js +7 -7
- package/src/service/markdown/xss.js +2 -2
- package/src/service/notify.js +13 -11
- package/src/service/storage/base.js +3 -1
- package/src/service/storage/cloudbase.js +1 -1
- package/src/service/storage/deta.js +5 -5
- package/src/service/storage/github.js +5 -5
- package/src/service/storage/leancloud.js +8 -6
- package/src/service/storage/mongodb.js +1 -1
- package/src/service/storage/mysql.js +2 -2
- package/src/service/storage/postgresql.js +1 -1
- package/src/service/storage/sqlite.js +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`inline mathjax > Should not render error msg when content is wrong 1`] = `
|
|
4
|
+
"<p><svg style=\\"vertical-align: -0.566ex;\\" xmlns=\\"http://www.w3.org/2000/svg\\" width=\\"6.009ex\\" height=\\"2.262ex\\" role=\\"img\\" focusable=\\"false\\" viewBox=\\"0 -750 2656 1000\\"><g stroke=\\"currentColor\\" fill=\\"currentColor\\" stroke-width=\\"0\\" transform=\\"scale(1,-1)\\"><g data-mml-node=\\"math\\"><g data-mml-node=\\"mtext\\" fill=\\"red\\" stroke=\\"red\\"><path data-c=\\"5C\\" d=\\"M56 731Q56 740 62 745T75 750Q85 750 92 740Q96 733 270 255T444 -231Q444 -239 438 -244T424 -250Q414 -250 407 -240Q404 -236 230 242T56 731Z\\"></path><path data-c=\\"66\\" d=\\"M273 0Q255 3 146 3Q43 3 34 0H26V46H42Q70 46 91 49Q99 52 103 60Q104 62 104 224V385H33V431H104V497L105 564L107 574Q126 639 171 668T266 704Q267 704 275 704T289 705Q330 702 351 679T372 627Q372 604 358 590T321 576T284 590T270 627Q270 647 288 667H284Q280 668 273 668Q245 668 223 647T189 592Q183 572 182 497V431H293V385H185V225Q185 63 186 61T189 57T194 54T199 51T206 49T213 48T222 47T231 47T241 46T251 46H282V0H273Z\\" transform=\\"translate(500,0)\\"></path><path data-c=\\"72\\" d=\\"M36 46H50Q89 46 97 60V68Q97 77 97 91T98 122T98 161T98 203Q98 234 98 269T98 328L97 351Q94 370 83 376T38 385H20V408Q20 431 22 431L32 432Q42 433 60 434T96 436Q112 437 131 438T160 441T171 442H174V373Q213 441 271 441H277Q322 441 343 419T364 373Q364 352 351 337T313 322Q288 322 276 338T263 372Q263 381 265 388T270 400T273 405Q271 407 250 401Q234 393 226 386Q179 341 179 207V154Q179 141 179 127T179 101T180 81T180 66V61Q181 59 183 57T188 54T193 51T200 49T207 48T216 47T225 47T235 46T245 46H276V0H267Q249 3 140 3Q37 3 28 0H20V46H36Z\\" transform=\\"translate(806,0)\\"></path><path data-c=\\"61\\" d=\\"M137 305T115 305T78 320T63 359Q63 394 97 421T218 448Q291 448 336 416T396 340Q401 326 401 309T402 194V124Q402 76 407 58T428 40Q443 40 448 56T453 109V145H493V106Q492 66 490 59Q481 29 455 12T400 -6T353 12T329 54V58L327 55Q325 52 322 49T314 40T302 29T287 17T269 6T247 -2T221 -8T190 -11Q130 -11 82 20T34 107Q34 128 41 147T68 188T116 225T194 253T304 268H318V290Q318 324 312 340Q290 411 215 411Q197 411 181 410T156 406T148 403Q170 388 170 359Q170 334 154 320ZM126 106Q126 75 150 51T209 26Q247 26 276 49T315 109Q317 116 318 175Q318 233 317 233Q309 233 296 232T251 223T193 203T147 166T126 106Z\\" transform=\\"translate(1198,0)\\"></path></g><g data-mml-node=\\"TeXAtom\\" data-mjx-texclass=\\"ORD\\" transform=\\"translate(1698,0)\\"><g data-mml-node=\\"mi\\"><path data-c=\\"1D44E\\" d=\\"M33 157Q33 258 109 349T280 441Q331 441 370 392Q386 422 416 422Q429 422 439 414T449 394Q449 381 412 234T374 68Q374 43 381 35T402 26Q411 27 422 35Q443 55 463 131Q469 151 473 152Q475 153 483 153H487Q506 153 506 144Q506 138 501 117T481 63T449 13Q436 0 417 -8Q409 -10 393 -10Q359 -10 336 5T306 36L300 51Q299 52 296 50Q294 48 292 46Q233 -10 172 -10Q117 -10 75 30T33 157ZM351 328Q351 334 346 350T323 385T277 405Q242 405 210 374T160 293Q131 214 119 129Q119 126 119 118T118 106Q118 61 136 44T179 26Q217 26 254 59T298 110Q300 114 325 217T351 328Z\\"></path></g></g><g data-mml-node=\\"TeXAtom\\" data-mjx-texclass=\\"ORD\\" transform=\\"translate(2227,0)\\"><g data-mml-node=\\"mi\\"><path data-c=\\"1D44F\\" d=\\"M73 647Q73 657 77 670T89 683Q90 683 161 688T234 694Q246 694 246 685T212 542Q204 508 195 472T180 418L176 399Q176 396 182 402Q231 442 283 442Q345 442 383 396T422 280Q422 169 343 79T173 -11Q123 -11 82 27T40 150V159Q40 180 48 217T97 414Q147 611 147 623T109 637Q104 637 101 637H96Q86 637 83 637T76 640T73 647ZM336 325V331Q336 405 275 405Q258 405 240 397T207 376T181 352T163 330L157 322L136 236Q114 150 114 114Q114 66 138 42Q154 26 178 26Q211 26 245 58Q270 81 285 114T318 219Q336 291 336 325Z\\"></path></g></g></g></g></svg></p>
|
|
5
|
+
"
|
|
6
|
+
`;
|
|
7
|
+
|
|
8
|
+
exports[`inline mathjax > Should render 1`] = `
|
|
9
|
+
"<p><svg style=\\"vertical-align: -0.186ex;\\" xmlns=\\"http://www.w3.org/2000/svg\\" width=\\"5.345ex\\" height=\\"1.692ex\\" role=\\"img\\" focusable=\\"false\\" viewBox=\\"0 -666 2362.6 748\\"><g stroke=\\"currentColor\\" fill=\\"currentColor\\" stroke-width=\\"0\\" transform=\\"scale(1,-1)\\"><g data-mml-node=\\"math\\"><g data-mml-node=\\"mi\\"><path data-c=\\"1D44E\\" d=\\"M33 157Q33 258 109 349T280 441Q331 441 370 392Q386 422 416 422Q429 422 439 414T449 394Q449 381 412 234T374 68Q374 43 381 35T402 26Q411 27 422 35Q443 55 463 131Q469 151 473 152Q475 153 483 153H487Q506 153 506 144Q506 138 501 117T481 63T449 13Q436 0 417 -8Q409 -10 393 -10Q359 -10 336 5T306 36L300 51Q299 52 296 50Q294 48 292 46Q233 -10 172 -10Q117 -10 75 30T33 157ZM351 328Q351 334 346 350T323 385T277 405Q242 405 210 374T160 293Q131 214 119 129Q119 126 119 118T118 106Q118 61 136 44T179 26Q217 26 254 59T298 110Q300 114 325 217T351 328Z\\"></path></g><g data-mml-node=\\"mo\\" transform=\\"translate(806.8,0)\\"><path data-c=\\"3D\\" d=\\"M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z\\"></path></g><g data-mml-node=\\"mn\\" transform=\\"translate(1862.6,0)\\"><path data-c=\\"31\\" d=\\"M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z\\"></path></g></g></g></svg></p>
|
|
10
|
+
"
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
exports[`inline mathjax > Should render when the first one is after a charater 1`] = `
|
|
14
|
+
"<p>The next<svg style=\\"vertical-align: -0.186ex;\\" xmlns=\\"http://www.w3.org/2000/svg\\" width=\\"5.345ex\\" height=\\"1.692ex\\" role=\\"img\\" focusable=\\"false\\" viewBox=\\"0 -666 2362.6 748\\"><g stroke=\\"currentColor\\" fill=\\"currentColor\\" stroke-width=\\"0\\" transform=\\"scale(1,-1)\\"><g data-mml-node=\\"math\\"><g data-mml-node=\\"mi\\"><path data-c=\\"1D44E\\" d=\\"M33 157Q33 258 109 349T280 441Q331 441 370 392Q386 422 416 422Q429 422 439 414T449 394Q449 381 412 234T374 68Q374 43 381 35T402 26Q411 27 422 35Q443 55 463 131Q469 151 473 152Q475 153 483 153H487Q506 153 506 144Q506 138 501 117T481 63T449 13Q436 0 417 -8Q409 -10 393 -10Q359 -10 336 5T306 36L300 51Q299 52 296 50Q294 48 292 46Q233 -10 172 -10Q117 -10 75 30T33 157ZM351 328Q351 334 346 350T323 385T277 405Q242 405 210 374T160 293Q131 214 119 129Q119 126 119 118T118 106Q118 61 136 44T179 26Q217 26 254 59T298 110Q300 114 325 217T351 328Z\\"></path></g><g data-mml-node=\\"mo\\" transform=\\"translate(806.8,0)\\"><path data-c=\\"3D\\" d=\\"M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z\\"></path></g><g data-mml-node=\\"mn\\" transform=\\"translate(1862.6,0)\\"><path data-c=\\"31\\" d=\\"M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z\\"></path></g></g></g></svg> won't work</p>
|
|
15
|
+
"
|
|
16
|
+
`;
|
package/__tests__/katex.spec.js
CHANGED
|
@@ -15,7 +15,7 @@ const markdownItWithError = MarkdownIt({ linkify: true }).use(katexPlugin, {
|
|
|
15
15
|
describe('inline katex', () => {
|
|
16
16
|
it('Should render', () => {
|
|
17
17
|
expect(markdownIt.render(`$a=1$`)).toEqual(
|
|
18
|
-
`<p><span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mo>=</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">a=1</annotation></semantics></math></span></p>\n
|
|
18
|
+
`<p><span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mo>=</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">a=1</annotation></semantics></math></span></p>\n`,
|
|
19
19
|
);
|
|
20
20
|
});
|
|
21
21
|
|
|
@@ -30,19 +30,19 @@ describe('inline katex', () => {
|
|
|
30
30
|
|
|
31
31
|
it('Should not render when the ending tag is followed by number', () => {
|
|
32
32
|
expect(markdownIt.render(`Of course $1 = $1`)).toEqual(
|
|
33
|
-
'<p>Of course $1 = $1</p>\n'
|
|
33
|
+
'<p>Of course $1 = $1</p>\n',
|
|
34
34
|
);
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
it('Should render when the first one is after a character', () => {
|
|
38
38
|
expect(markdownIt.render(`The next$a = 1$ won't work`)).toEqual(
|
|
39
|
-
`<p>The next<span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mo>=</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">a = 1</annotation></semantics></math></span> won't work</p>\n
|
|
39
|
+
`<p>The next<span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>a</mi><mo>=</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">a = 1</annotation></semantics></math></span> won't work</p>\n`,
|
|
40
40
|
);
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
it('Should not render error msg when content is wrong', () => {
|
|
44
44
|
expect(markdownIt.render('$\\fra{a}{b}$')).toEqual(
|
|
45
|
-
`<p><span class='katex-error' title='ParseError: KaTeX parse error: Undefined control sequence: \\fra at position 1: \\̲f̲r̲a̲{a}{b}'>\\fra{a}{b}</span></p>\n
|
|
45
|
+
`<p><span class='katex-error' title='ParseError: KaTeX parse error: Undefined control sequence: \\fra at position 1: \\̲f̲r̲a̲{a}{b}'>\\fra{a}{b}</span></p>\n`,
|
|
46
46
|
);
|
|
47
47
|
});
|
|
48
48
|
|
|
@@ -52,7 +52,7 @@ describe('inline katex', () => {
|
|
|
52
52
|
global.console.warn = vi.fn();
|
|
53
53
|
|
|
54
54
|
expect(markdownItWithError.render('$\\fra{a}{b}$')).toEqual(
|
|
55
|
-
"<p><span class='katex-error' title='ParseError: KaTeX parse error: Undefined control sequence: \\fra at position 1: \\̲f̲r̲a̲{a}{b}'>\\fra{a}{b}</span></p>\n"
|
|
55
|
+
"<p><span class='katex-error' title='ParseError: KaTeX parse error: Undefined control sequence: \\fra at position 1: \\̲f̲r̲a̲{a}{b}'>\\fra{a}{b}</span></p>\n",
|
|
56
56
|
);
|
|
57
57
|
|
|
58
58
|
expect(global.console.warn).toHaveBeenCalledTimes(1);
|
|
@@ -63,7 +63,7 @@ describe('inline katex', () => {
|
|
|
63
63
|
describe('block katex', () => {
|
|
64
64
|
it('Should render', () => {
|
|
65
65
|
expect(markdownIt.render(`$$a=1$$`)).toEqual(
|
|
66
|
-
`<p class='katex-block'><span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>a</mi><mo>=</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">a=1\n</annotation></semantics></math></span></p>\n
|
|
66
|
+
`<p class='katex-block'><span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>a</mi><mo>=</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">a=1\n</annotation></semantics></math></span></p>\n`,
|
|
67
67
|
);
|
|
68
68
|
|
|
69
69
|
expect(
|
|
@@ -71,9 +71,9 @@ describe('block katex', () => {
|
|
|
71
71
|
$$
|
|
72
72
|
a = 1
|
|
73
73
|
$$
|
|
74
|
-
`)
|
|
74
|
+
`),
|
|
75
75
|
).toEqual(
|
|
76
|
-
`<p class='katex-block'><span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>a</mi><mo>=</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">a = 1\n</annotation></semantics></math></span></p>\n
|
|
76
|
+
`<p class='katex-block'><span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>a</mi><mo>=</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">a = 1\n</annotation></semantics></math></span></p>\n`,
|
|
77
77
|
);
|
|
78
78
|
});
|
|
79
79
|
|
|
@@ -84,7 +84,7 @@ $$
|
|
|
84
84
|
\\$\\$
|
|
85
85
|
a = 1
|
|
86
86
|
\\$\\$
|
|
87
|
-
`)
|
|
87
|
+
`),
|
|
88
88
|
).toEqual(`<p>$$
|
|
89
89
|
a = 1
|
|
90
90
|
$$</p>\n`);
|
|
@@ -92,17 +92,17 @@ $$</p>\n`);
|
|
|
92
92
|
|
|
93
93
|
it('Should render when having spaces', () => {
|
|
94
94
|
expect(markdownIt.render(`$$ a = 1 $$`)).toEqual(
|
|
95
|
-
`<p class='katex-block'><span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>a</mi><mo>=</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">a = 1 \n</annotation></semantics></math></span></p>\n
|
|
95
|
+
`<p class='katex-block'><span class="katex"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>a</mi><mo>=</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">a = 1 \n</annotation></semantics></math></span></p>\n`,
|
|
96
96
|
);
|
|
97
97
|
|
|
98
98
|
expect(markdownIt.render(`All $$ a = 1 $$ is true.`)).toEqual(
|
|
99
|
-
'<p>All $$ a = 1 $$ is true.</p>\n'
|
|
99
|
+
'<p>All $$ a = 1 $$ is true.</p>\n',
|
|
100
100
|
);
|
|
101
101
|
});
|
|
102
102
|
|
|
103
103
|
it('Should not render error msg when content is wrong', () => {
|
|
104
104
|
expect(markdownIt.render('$$\\fra{a}{b}$$')).toEqual(
|
|
105
|
-
`<p class='katex-block katex-error' title='ParseError: KaTeX parse error: Undefined control sequence: \\fra at position 1: \\̲f̲r̲a̲{a}{b}\n'>\\fra{a}{b}\n</p>\n
|
|
105
|
+
`<p class='katex-block katex-error' title='ParseError: KaTeX parse error: Undefined control sequence: \\fra at position 1: \\̲f̲r̲a̲{a}{b}\n'>\\fra{a}{b}\n</p>\n`,
|
|
106
106
|
);
|
|
107
107
|
|
|
108
108
|
expect(
|
|
@@ -110,9 +110,9 @@ $$</p>\n`);
|
|
|
110
110
|
$$
|
|
111
111
|
\\fra{a}{b}
|
|
112
112
|
$$
|
|
113
|
-
`)
|
|
113
|
+
`),
|
|
114
114
|
).toEqual(
|
|
115
|
-
`<p class='katex-block katex-error' title='ParseError: KaTeX parse error: Undefined control sequence: \\fra at position 1: \\̲f̲r̲a̲{a}{b}\n'>\\fra{a}{b}\n</p>\n
|
|
115
|
+
`<p class='katex-block katex-error' title='ParseError: KaTeX parse error: Undefined control sequence: \\fra at position 1: \\̲f̲r̲a̲{a}{b}\n'>\\fra{a}{b}\n</p>\n`,
|
|
116
116
|
);
|
|
117
117
|
});
|
|
118
118
|
|
|
@@ -121,7 +121,7 @@ $$
|
|
|
121
121
|
|
|
122
122
|
global.console.warn = vi.fn();
|
|
123
123
|
expect(markdownItWithError.render('$$\\fra{a}{b}$$')).toMatch(
|
|
124
|
-
/<p class='katex-block katex-error' title='[\s\S]*?'>[\s\S]*?<\/p
|
|
124
|
+
/<p class='katex-block katex-error' title='[\s\S]*?'>[\s\S]*?<\/p>/,
|
|
125
125
|
);
|
|
126
126
|
|
|
127
127
|
expect(
|
|
@@ -129,9 +129,9 @@ $$
|
|
|
129
129
|
$$
|
|
130
130
|
\\fra{a}{b}
|
|
131
131
|
$$
|
|
132
|
-
`)
|
|
132
|
+
`),
|
|
133
133
|
).toMatch(
|
|
134
|
-
/<p class='katex-block katex-error' title='[\s\S]*?'>[\s\S]*?<\/p
|
|
134
|
+
/<p class='katex-block katex-error' title='[\s\S]*?'>[\s\S]*?<\/p>/,
|
|
135
135
|
);
|
|
136
136
|
|
|
137
137
|
expect(global.console.warn).toHaveBeenCalledTimes(2);
|
|
@@ -7,9 +7,7 @@ const markdownIt = MarkdownIt({ linkify: true }).use(mathjaxPlugin);
|
|
|
7
7
|
|
|
8
8
|
describe('inline mathjax', () => {
|
|
9
9
|
it('Should render', () => {
|
|
10
|
-
expect(markdownIt.render(`$a=1$`)).
|
|
11
|
-
`<p><svg style="vertical-align: -0.186ex" xmlns="http://www.w3.org/2000/svg" width="5.345ex" height="1.692ex" role="img" focusable="false" viewBox="0 -666 2362.6 748"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math"><g data-mml-node="mi"><path data-c="1D44E" d="M33 157Q33 258 109 349T280 441Q331 441 370 392Q386 422 416 422Q429 422 439 414T449 394Q449 381 412 234T374 68Q374 43 381 35T402 26Q411 27 422 35Q443 55 463 131Q469 151 473 152Q475 153 483 153H487Q506 153 506 144Q506 138 501 117T481 63T449 13Q436 0 417 -8Q409 -10 393 -10Q359 -10 336 5T306 36L300 51Q299 52 296 50Q294 48 292 46Q233 -10 172 -10Q117 -10 75 30T33 157ZM351 328Q351 334 346 350T323 385T277 405Q242 405 210 374T160 293Q131 214 119 129Q119 126 119 118T118 106Q118 61 136 44T179 26Q217 26 254 59T298 110Q300 114 325 217T351 328Z"></path></g><g data-mml-node="mo" transform="translate(806.8,0)"><path data-c="3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"></path></g><g data-mml-node="mn" transform="translate(1862.6,0)"><path data-c="31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"></path></g></g></g></svg></p>\n`
|
|
12
|
-
);
|
|
10
|
+
expect(markdownIt.render(`$a=1$`)).toMatchSnapshot();
|
|
13
11
|
});
|
|
14
12
|
|
|
15
13
|
it('Should not render when escape', () => {
|
|
@@ -23,38 +21,34 @@ describe('inline mathjax', () => {
|
|
|
23
21
|
|
|
24
22
|
it('Should not render when the ending tag is followed by number', () => {
|
|
25
23
|
expect(markdownIt.render(`Of course $1 = $1`)).toEqual(
|
|
26
|
-
'<p>Of course $1 = $1</p>\n'
|
|
24
|
+
'<p>Of course $1 = $1</p>\n',
|
|
27
25
|
);
|
|
28
26
|
});
|
|
29
27
|
|
|
30
28
|
it('Should render when the first one is after a charater', () => {
|
|
31
|
-
expect(markdownIt.render(`The next$a = 1$ won't work`)).
|
|
32
|
-
`<p>The next<svg style="vertical-align: -0.186ex" xmlns="http://www.w3.org/2000/svg" width="5.345ex" height="1.692ex" role="img" focusable="false" viewBox="0 -666 2362.6 748"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math"><g data-mml-node="mi"><path data-c="1D44E" d="M33 157Q33 258 109 349T280 441Q331 441 370 392Q386 422 416 422Q429 422 439 414T449 394Q449 381 412 234T374 68Q374 43 381 35T402 26Q411 27 422 35Q443 55 463 131Q469 151 473 152Q475 153 483 153H487Q506 153 506 144Q506 138 501 117T481 63T449 13Q436 0 417 -8Q409 -10 393 -10Q359 -10 336 5T306 36L300 51Q299 52 296 50Q294 48 292 46Q233 -10 172 -10Q117 -10 75 30T33 157ZM351 328Q351 334 346 350T323 385T277 405Q242 405 210 374T160 293Q131 214 119 129Q119 126 119 118T118 106Q118 61 136 44T179 26Q217 26 254 59T298 110Q300 114 325 217T351 328Z"></path></g><g data-mml-node="mo" transform="translate(806.8,0)"><path data-c="3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"></path></g><g data-mml-node="mn" transform="translate(1862.6,0)"><path data-c="31" d="M213 578L200 573Q186 568 160 563T102 556H83V602H102Q149 604 189 617T245 641T273 663Q275 666 285 666Q294 666 302 660V361L303 61Q310 54 315 52T339 48T401 46H427V0H416Q395 3 257 3Q121 3 100 0H88V46H114Q136 46 152 46T177 47T193 50T201 52T207 57T213 61V578Z"></path></g></g></g></svg> won't work</p>\n`
|
|
33
|
-
);
|
|
29
|
+
expect(markdownIt.render(`The next$a = 1$ won't work`)).toMatchSnapshot();
|
|
34
30
|
});
|
|
35
31
|
|
|
36
32
|
it('Should not render error msg when content is wrong', () => {
|
|
37
|
-
expect(markdownIt.render('$\\fra{a}{b}$')).
|
|
38
|
-
`<p><svg style="vertical-align: -0.566ex" xmlns="http://www.w3.org/2000/svg" width="6.009ex" height="2.262ex" role="img" focusable="false" viewBox="0 -750 2656 1000"><g stroke="currentColor" fill="currentColor" stroke-width="0" transform="scale(1,-1)"><g data-mml-node="math"><g data-mml-node="mtext" fill="red" stroke="red"><path data-c="5C" d="M56 731Q56 740 62 745T75 750Q85 750 92 740Q96 733 270 255T444 -231Q444 -239 438 -244T424 -250Q414 -250 407 -240Q404 -236 230 242T56 731Z"></path><path data-c="66" d="M273 0Q255 3 146 3Q43 3 34 0H26V46H42Q70 46 91 49Q99 52 103 60Q104 62 104 224V385H33V431H104V497L105 564L107 574Q126 639 171 668T266 704Q267 704 275 704T289 705Q330 702 351 679T372 627Q372 604 358 590T321 576T284 590T270 627Q270 647 288 667H284Q280 668 273 668Q245 668 223 647T189 592Q183 572 182 497V431H293V385H185V225Q185 63 186 61T189 57T194 54T199 51T206 49T213 48T222 47T231 47T241 46T251 46H282V0H273Z" transform="translate(500,0)"></path><path data-c="72" d="M36 46H50Q89 46 97 60V68Q97 77 97 91T98 122T98 161T98 203Q98 234 98 269T98 328L97 351Q94 370 83 376T38 385H20V408Q20 431 22 431L32 432Q42 433 60 434T96 436Q112 437 131 438T160 441T171 442H174V373Q213 441 271 441H277Q322 441 343 419T364 373Q364 352 351 337T313 322Q288 322 276 338T263 372Q263 381 265 388T270 400T273 405Q271 407 250 401Q234 393 226 386Q179 341 179 207V154Q179 141 179 127T179 101T180 81T180 66V61Q181 59 183 57T188 54T193 51T200 49T207 48T216 47T225 47T235 46T245 46H276V0H267Q249 3 140 3Q37 3 28 0H20V46H36Z" transform="translate(806,0)"></path><path data-c="61" d="M137 305T115 305T78 320T63 359Q63 394 97 421T218 448Q291 448 336 416T396 340Q401 326 401 309T402 194V124Q402 76 407 58T428 40Q443 40 448 56T453 109V145H493V106Q492 66 490 59Q481 29 455 12T400 -6T353 12T329 54V58L327 55Q325 52 322 49T314 40T302 29T287 17T269 6T247 -2T221 -8T190 -11Q130 -11 82 20T34 107Q34 128 41 147T68 188T116 225T194 253T304 268H318V290Q318 324 312 340Q290 411 215 411Q197 411 181 410T156 406T148 403Q170 388 170 359Q170 334 154 320ZM126 106Q126 75 150 51T209 26Q247 26 276 49T315 109Q317 116 318 175Q318 233 317 233Q309 233 296 232T251 223T193 203T147 166T126 106Z" transform="translate(1198,0)"></path></g><g data-mml-node="TeXAtom" data-mjx-texclass="ORD" transform="translate(1698,0)"><g data-mml-node="mi"><path data-c="1D44E" d="M33 157Q33 258 109 349T280 441Q331 441 370 392Q386 422 416 422Q429 422 439 414T449 394Q449 381 412 234T374 68Q374 43 381 35T402 26Q411 27 422 35Q443 55 463 131Q469 151 473 152Q475 153 483 153H487Q506 153 506 144Q506 138 501 117T481 63T449 13Q436 0 417 -8Q409 -10 393 -10Q359 -10 336 5T306 36L300 51Q299 52 296 50Q294 48 292 46Q233 -10 172 -10Q117 -10 75 30T33 157ZM351 328Q351 334 346 350T323 385T277 405Q242 405 210 374T160 293Q131 214 119 129Q119 126 119 118T118 106Q118 61 136 44T179 26Q217 26 254 59T298 110Q300 114 325 217T351 328Z"></path></g></g><g data-mml-node="TeXAtom" data-mjx-texclass="ORD" transform="translate(2227,0)"><g data-mml-node="mi"><path data-c="1D44F" d="M73 647Q73 657 77 670T89 683Q90 683 161 688T234 694Q246 694 246 685T212 542Q204 508 195 472T180 418L176 399Q176 396 182 402Q231 442 283 442Q345 442 383 396T422 280Q422 169 343 79T173 -11Q123 -11 82 27T40 150V159Q40 180 48 217T97 414Q147 611 147 623T109 637Q104 637 101 637H96Q86 637 83 637T76 640T73 647ZM336 325V331Q336 405 275 405Q258 405 240 397T207 376T181 352T163 330L157 322L136 236Q114 150 114 114Q114 66 138 42Q154 26 178 26Q211 26 245 58Q270 81 285 114T318 219Q336 291 336 325Z"></path></g></g></g></g></svg></p>\n`
|
|
39
|
-
);
|
|
33
|
+
expect(markdownIt.render('$\\fra{a}{b}$')).toMatchSnapshot();
|
|
40
34
|
});
|
|
41
35
|
});
|
|
42
36
|
|
|
43
37
|
describe('block mathjax', () => {
|
|
44
38
|
it('Should render', () => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
expect(
|
|
50
|
-
markdownIt.render(`
|
|
39
|
+
const result1 = markdownIt.render(`$$a=1$$`);
|
|
40
|
+
const result2 = markdownIt.render(`
|
|
51
41
|
$$
|
|
52
42
|
a = 1
|
|
53
43
|
$$
|
|
54
|
-
`)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
);
|
|
44
|
+
`);
|
|
45
|
+
|
|
46
|
+
expect(result1).toMatch(/^<svg/);
|
|
47
|
+
expect(result1).toMatch(/<\/svg>$/);
|
|
48
|
+
expect(result1).toMatchSnapshot();
|
|
49
|
+
expect(result2).toMatch(/^<svg/);
|
|
50
|
+
expect(result2).toMatch(/<\/svg>$/);
|
|
51
|
+
expect(result2).toMatchSnapshot();
|
|
58
52
|
});
|
|
59
53
|
|
|
60
54
|
it('Should not render when escape', () => {
|
|
@@ -64,35 +58,37 @@ $$
|
|
|
64
58
|
\\$\\$
|
|
65
59
|
a = 1
|
|
66
60
|
\\$\\$
|
|
67
|
-
`)
|
|
61
|
+
`),
|
|
68
62
|
).toEqual(`<p>$$
|
|
69
63
|
a = 1
|
|
70
64
|
$$</p>\n`);
|
|
71
65
|
});
|
|
72
66
|
|
|
73
67
|
it('Should render when having spaces', () => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
);
|
|
68
|
+
const result1 = markdownIt.render(`$$ a = 1 $$`);
|
|
69
|
+
|
|
70
|
+
expect(result1).toMatch(/^<svg/);
|
|
71
|
+
expect(result1).toMatch(/<\/svg>$/);
|
|
72
|
+
expect(result1).toMatchSnapshot();
|
|
77
73
|
|
|
78
74
|
expect(markdownIt.render(`All $$ a = 1 $$ is true.`)).toEqual(
|
|
79
|
-
'<p>All $$ a = 1 $$ is true.</p>\n'
|
|
75
|
+
'<p>All $$ a = 1 $$ is true.</p>\n',
|
|
80
76
|
);
|
|
81
77
|
});
|
|
82
78
|
|
|
83
79
|
it('Should not render error msg when content is wrong', () => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
expect(
|
|
89
|
-
markdownIt.render(`
|
|
80
|
+
const result1 = markdownIt.render('$$\\fra{a}{b}$$');
|
|
81
|
+
const result2 = markdownIt.render(`
|
|
90
82
|
$$
|
|
91
83
|
\\fra{a}{b}
|
|
92
84
|
$$
|
|
93
|
-
`)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
);
|
|
85
|
+
`);
|
|
86
|
+
|
|
87
|
+
expect(result1).toMatch(/^<svg/);
|
|
88
|
+
expect(result1).toMatch(/<\/svg>$/);
|
|
89
|
+
expect(result1).toMatchSnapshot();
|
|
90
|
+
expect(result2).toMatch(/^<svg/);
|
|
91
|
+
expect(result2).toMatch(/<\/svg>$/);
|
|
92
|
+
expect(result2).toMatchSnapshot();
|
|
97
93
|
});
|
|
98
94
|
});
|
package/__tests__/xss.spec.js
CHANGED
|
@@ -37,53 +37,53 @@ Waline is a good framework. :money:
|
|
|
37
37
|
|
|
38
38
|
it('Should protect', () => {
|
|
39
39
|
expect(parser(`<img src="x" onerror="alert('img')">`)).toEqual(
|
|
40
|
-
'<img src="x">'
|
|
40
|
+
'<img src="x">',
|
|
41
41
|
);
|
|
42
42
|
expect(parser('<script>alert("hello world")</script>')).toEqual('');
|
|
43
43
|
|
|
44
44
|
expect(
|
|
45
45
|
parser(
|
|
46
|
-
'<p>Waline is <iframe//src=jaVa	script:alert(3)></iframe>awesome</p>'
|
|
47
|
-
)
|
|
46
|
+
'<p>Waline is <iframe//src=jaVa	script:alert(3)></iframe>awesome</p>',
|
|
47
|
+
),
|
|
48
48
|
).toEqual('<p>Waline is awesome</p>');
|
|
49
49
|
|
|
50
50
|
expect(
|
|
51
|
-
parser('<p>Waline is <iframe//src=jaVa	script:alert(3)>awesome</p>')
|
|
51
|
+
parser('<p>Waline is <iframe//src=jaVa	script:alert(3)>awesome</p>'),
|
|
52
52
|
).toEqual('<p>Waline is </p>');
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
it('Should resolve unmatching html tags', () => {
|
|
56
56
|
expect(parser('<TABLE><tr><td>HELLO</a></TAB>\n<p>Waline</p>')).toEqual(
|
|
57
|
-
'<table><tbody><tr><td>HELLO\n<p>Waline</p></td></tr></tbody></table>'
|
|
57
|
+
'<table><tbody><tr><td>HELLO\n<p>Waline</p></td></tr></tbody></table>',
|
|
58
58
|
);
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
it('Should not autoplay or preload media', () => {
|
|
62
62
|
expect(parser('<audio autoplay preload="auto" src="x">')).toEqual(
|
|
63
|
-
'<audio src="x" preload="none"></audio>'
|
|
63
|
+
'<audio src="x" preload="none"></audio>',
|
|
64
64
|
);
|
|
65
65
|
expect(parser('<audio autoplay src="x"></audio>')).toEqual(
|
|
66
|
-
'<p><audio src="x" preload="none"></audio></p>\n'
|
|
66
|
+
'<p><audio src="x" preload="none"></audio></p>\n',
|
|
67
67
|
);
|
|
68
68
|
|
|
69
69
|
expect(parser('<video autoplay preload="auto" src="x">')).toEqual(
|
|
70
|
-
'<video src="x" preload="none"></video>'
|
|
70
|
+
'<video src="x" preload="none"></video>',
|
|
71
71
|
);
|
|
72
72
|
expect(parser('<video autoplay src="x"></video>')).toEqual(
|
|
73
|
-
'<p><video src="x" preload="none"></video></p>\n'
|
|
73
|
+
'<p><video src="x" preload="none"></video></p>\n',
|
|
74
74
|
);
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
it('Should resolve links', () => {
|
|
78
78
|
expect(parser('[link](https://example.com)')).toEqual(
|
|
79
|
-
'<p><a href="https://example.com" target="_blank" rel="noreferrer noopener">link</a></p>\n'
|
|
79
|
+
'<p><a href="https://example.com" target="_blank" rel="nofollow noreferrer noopener">link</a></p>\n',
|
|
80
80
|
);
|
|
81
81
|
expect(
|
|
82
82
|
parser(
|
|
83
|
-
'<p><a href="https://example.com" rel="opener prefetch">link</a></p>'
|
|
84
|
-
)
|
|
83
|
+
'<p><a href="https://example.com" rel="opener prefetch">link</a></p>',
|
|
84
|
+
),
|
|
85
85
|
).toEqual(
|
|
86
|
-
'<p><a rel="noreferrer noopener" href="https://example.com" target="_blank">link</a></p>'
|
|
86
|
+
'<p><a rel="nofollow noreferrer noopener" href="https://example.com" target="_blank">link</a></p>',
|
|
87
87
|
);
|
|
88
88
|
});
|
|
89
89
|
|
|
@@ -95,13 +95,13 @@ Waline is a good framework. :money:
|
|
|
95
95
|
it('Should forbid style', () => {
|
|
96
96
|
expect(
|
|
97
97
|
parser(
|
|
98
|
-
'<div style="position:fixed;top:0;left:0;width:100vh;height:100vh;">广告文字</div>'
|
|
99
|
-
)
|
|
98
|
+
'<div style="position:fixed;top:0;left:0;width:100vh;height:100vh;">广告文字</div>',
|
|
99
|
+
),
|
|
100
100
|
).toEqual('<div>广告文字</div>');
|
|
101
101
|
expect(
|
|
102
102
|
parser(
|
|
103
|
-
'<div id="ad">广告文字</div><style>#ad{position:fixed;top:0;left:0;width:100vh;height:100vh;}</style>'
|
|
104
|
-
)
|
|
103
|
+
'<div id="ad">广告文字</div><style>#ad{position:fixed;top:0;left:0;width:100vh;height:100vh;}</style>',
|
|
104
|
+
),
|
|
105
105
|
).toEqual('<div id="ad">广告文字</div>');
|
|
106
106
|
});
|
|
107
107
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waline/vercel",
|
|
3
|
-
"version": "1.31.
|
|
3
|
+
"version": "1.31.4",
|
|
4
4
|
"description": "vercel server for waline comment system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"waline",
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"author": "lizheming <i@imnerd.org>",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@cloudbase/node-sdk": "^2.
|
|
18
|
+
"@cloudbase/node-sdk": "^2.11.0",
|
|
19
19
|
"@koa/cors": "^4.0.0",
|
|
20
20
|
"akismet": "^2.0.7",
|
|
21
|
-
"deta": "^1.
|
|
22
|
-
"dompurify": "^3.0.
|
|
21
|
+
"deta": "^1.2.0",
|
|
22
|
+
"dompurify": "^3.0.5",
|
|
23
23
|
"dy-node-ip2region": "^1.0.1",
|
|
24
24
|
"fast-csv": "^4.3.6",
|
|
25
25
|
"form-data": "^4.0.0",
|
|
26
26
|
"jsdom": "^22.1.0",
|
|
27
|
-
"jsonwebtoken": "^9.0.
|
|
28
|
-
"katex": "^0.16.
|
|
27
|
+
"jsonwebtoken": "^9.0.1",
|
|
28
|
+
"katex": "^0.16.8",
|
|
29
29
|
"koa-compose": "^4.1.0",
|
|
30
30
|
"leancloud-storage": "^4.15.0",
|
|
31
31
|
"markdown-it": "^13.0.1",
|
|
@@ -33,22 +33,22 @@
|
|
|
33
33
|
"markdown-it-sub": "^1.0.0",
|
|
34
34
|
"markdown-it-sup": "^1.0.0",
|
|
35
35
|
"mathjax-full": "^3.2.2",
|
|
36
|
-
"node-fetch": "^2.
|
|
37
|
-
"nodemailer": "^6.9.
|
|
36
|
+
"node-fetch": "^2.7.0",
|
|
37
|
+
"nodemailer": "^6.9.4",
|
|
38
38
|
"nunjucks": "^3.2.4",
|
|
39
39
|
"phpass": "^0.1.1",
|
|
40
40
|
"prismjs": "^1.29.0",
|
|
41
41
|
"speakeasy": "^2.0.0",
|
|
42
42
|
"think-helper": "^1.1.4",
|
|
43
|
-
"think-logger3": "^1.
|
|
43
|
+
"think-logger3": "^1.4.0",
|
|
44
44
|
"think-model": "^1.5.4",
|
|
45
45
|
"think-model-mysql": "^1.1.7",
|
|
46
46
|
"think-model-mysql2": "^2.0.0",
|
|
47
47
|
"think-model-postgresql": "1.1.7",
|
|
48
|
-
"think-model-sqlite": "^1.3.
|
|
48
|
+
"think-model-sqlite": "^1.3.2",
|
|
49
49
|
"think-mongo": "^2.2.1",
|
|
50
50
|
"think-router-rest": "^1.0.5",
|
|
51
|
-
"thinkjs": "^3.2.
|
|
51
|
+
"thinkjs": "^3.2.15",
|
|
52
52
|
"ua-parser-js": "^1.0.35"
|
|
53
53
|
},
|
|
54
54
|
"engines": {
|
package/src/config/netlify.js
CHANGED
|
@@ -25,7 +25,7 @@ module.exports = class extends BaseRest {
|
|
|
25
25
|
}, {});
|
|
26
26
|
|
|
27
27
|
return this.jsonOrSuccess(
|
|
28
|
-
type.length === 1 && deprecated ? data[type[0]] : data
|
|
28
|
+
type.length === 1 && deprecated ? data[type[0]] : data,
|
|
29
29
|
);
|
|
30
30
|
}
|
|
31
31
|
|
|
@@ -71,7 +71,7 @@ module.exports = class extends BaseRest {
|
|
|
71
71
|
|
|
72
72
|
await this.modelInstance.add(
|
|
73
73
|
{ url: path, [type]: count },
|
|
74
|
-
{ access: { read: true, write: true } }
|
|
74
|
+
{ access: { read: true, write: true } },
|
|
75
75
|
);
|
|
76
76
|
|
|
77
77
|
return this.jsonOrSuccess(deprecated ? count : [count]);
|
|
@@ -83,8 +83,9 @@ module.exports = class extends BaseRest {
|
|
|
83
83
|
action === 'desc'
|
|
84
84
|
? (counter[type] || 1) - 1
|
|
85
85
|
: (counter[type] || 0) + 1,
|
|
86
|
+
updatedAt: new Date(),
|
|
86
87
|
}),
|
|
87
|
-
{ objectId: ['IN', resp.map(({ objectId }) => objectId)] }
|
|
88
|
+
{ objectId: ['IN', resp.map(({ objectId }) => objectId)] },
|
|
88
89
|
);
|
|
89
90
|
|
|
90
91
|
return this.jsonOrSuccess(deprecated ? ret[0][type] : [ret[0][type]]);
|