@waline/vercel 1.18.0 → 1.18.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/.eslintrc.yml +7 -0
- package/__tests__/__snapshots__/xss.spec.js.snap +2 -2
- package/__tests__/katex.spec.js +6 -4
- package/__tests__/mathjax.spec.js +3 -2
- package/__tests__/xss.spec.js +4 -2
- package/index.js +2 -2
- package/package.json +4 -1
- package/src/config/config.js +1 -1
- package/src/controller/comment.js +9 -2
- package/src/controller/db.js +2 -2
- package/src/controller/oauth.js +1 -1
- package/src/controller/rest.js +1 -1
- package/src/controller/user.js +1 -1
- package/src/service/storage/github.js +1 -1
- package/vanilla.js +1 -1
package/.eslintrc.yml
CHANGED
package/__tests__/katex.spec.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import MarkdownIt from 'markdown-it';
|
|
3
|
+
import { katexPlugin } from '../src/service/markdown/katex';
|
|
4
|
+
import { vi } from 'vitest';
|
|
3
5
|
|
|
4
6
|
const markdownIt = MarkdownIt({ linkify: true }).use(katexPlugin, {
|
|
5
7
|
output: 'mathml',
|
|
@@ -46,7 +48,7 @@ describe('inline katex', () => {
|
|
|
46
48
|
it('Should render error msg when content is wrong', () => {
|
|
47
49
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
48
50
|
const originalWarn = global.console.warn;
|
|
49
|
-
global.console.warn =
|
|
51
|
+
global.console.warn = vi.fn();
|
|
50
52
|
|
|
51
53
|
expect(markdownItWithError.render('$\\fra{a}{b}$')).toEqual(
|
|
52
54
|
"<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"
|
|
@@ -117,7 +119,7 @@ $$
|
|
|
117
119
|
it('Should render error msg when content is wrong', () => {
|
|
118
120
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
119
121
|
const originalWarn = global.console.warn;
|
|
120
|
-
global.console.warn =
|
|
122
|
+
global.console.warn = vi.fn();
|
|
121
123
|
expect(markdownItWithError.render('$$\\fra{a}{b}$$')).toMatch(
|
|
122
124
|
/<p class='katex-block katex-error' title='[\s\S]*?'>[\s\S]*?<\/p>/
|
|
123
125
|
);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import MarkdownIt from 'markdown-it';
|
|
3
|
+
import { mathjaxPlugin } from '../src/service/markdown/mathjax';
|
|
3
4
|
|
|
4
5
|
const markdownIt = MarkdownIt({ linkify: true }).use(mathjaxPlugin);
|
|
5
6
|
|
package/__tests__/xss.spec.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import MarkdownIt from 'markdown-it';
|
|
3
|
+
import { sanitize } from '../src/service/markdown/xss';
|
|
4
|
+
|
|
3
5
|
const parser = (content) =>
|
|
4
6
|
sanitize(new MarkdownIt({ html: true }).render(content));
|
|
5
7
|
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waline/vercel",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.1",
|
|
4
4
|
"description": "vercel server for waline comment system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"waline",
|
|
@@ -47,5 +47,8 @@
|
|
|
47
47
|
"think-router-rest": "^1.0.5",
|
|
48
48
|
"thinkjs": "^3.2.14",
|
|
49
49
|
"ua-parser-js": "^1.0.2"
|
|
50
|
+
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">=14"
|
|
50
53
|
}
|
|
51
54
|
}
|
package/src/config/config.js
CHANGED
|
@@ -92,7 +92,7 @@ const markdown = {
|
|
|
92
92
|
|
|
93
93
|
if (isFalse(MARKDOWN_HIGHLIGHT)) markdown.config.highlight = false;
|
|
94
94
|
|
|
95
|
-
let avatarProxy = '
|
|
95
|
+
let avatarProxy = '';
|
|
96
96
|
if (AVATAR_PROXY) {
|
|
97
97
|
avatarProxy = !isFalse(AVATAR_PROXY) ? AVATAR_PROXY : '';
|
|
98
98
|
}
|
|
@@ -556,7 +556,10 @@ module.exports = class extends BaseRest {
|
|
|
556
556
|
|
|
557
557
|
if (comment.status !== 'spam') {
|
|
558
558
|
const notify = this.service('notify');
|
|
559
|
-
await notify.run(
|
|
559
|
+
await notify.run(
|
|
560
|
+
{ ...resp, comment: markdownParser(resp.comment), rawComment: comment },
|
|
561
|
+
{ ...parentComment, comment: markdownParser(parentComment.comment) }
|
|
562
|
+
);
|
|
560
563
|
}
|
|
561
564
|
|
|
562
565
|
think.logger.debug(`Comment notify done!`);
|
|
@@ -616,7 +619,11 @@ module.exports = class extends BaseRest {
|
|
|
616
619
|
pComment = pComment[0];
|
|
617
620
|
|
|
618
621
|
const notify = this.service('notify');
|
|
619
|
-
await notify.run(
|
|
622
|
+
await notify.run(
|
|
623
|
+
{ ...newData, comment: markdownParser(newData.comment) },
|
|
624
|
+
{ ...pComment, comment: markdownParser(pComment.comment) },
|
|
625
|
+
true
|
|
626
|
+
);
|
|
620
627
|
}
|
|
621
628
|
|
|
622
629
|
await this.hook('postUpdate', data);
|
package/src/controller/db.js
CHANGED
package/src/controller/oauth.js
CHANGED
package/src/controller/rest.js
CHANGED
package/src/controller/user.js
CHANGED
package/vanilla.js
CHANGED