Skip to content

Commit 4e642d9

Browse files
authored
Revert "chore: Remove dompurify (#1490)"
This reverts commit e2c0853.
1 parent b787e6c commit 4e642d9

File tree

6 files changed

+135
-279
lines changed

6 files changed

+135
-279
lines changed

Diff for: package-lock.json

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"*.js": "eslint --fix"
6666
},
6767
"dependencies": {
68+
"dompurify": "^2.3.1",
6869
"marked": "^1.2.9",
6970
"medium-zoom": "^1.0.6",
7071
"opencollective-postinstall": "^2.0.2",

Diff for: packages/docsify-server-renderer/index.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { resolve, basename } from 'path';
33
import resolvePathname from 'resolve-pathname';
44
import fetch from 'node-fetch';
55
import debug from 'debug';
6+
import DOMPurify from 'dompurify';
67
import { AbstractHistory } from '../../src/core/router/history/abstract';
78
import { Compiler } from '../../src/core/render/compiler';
89
import { isAbsolutePath } from '../../src/core/router/util';
@@ -122,10 +123,10 @@ export default class Renderer {
122123
this._renderHtml('cover', await this._render(coverFile), 'cover');
123124
}
124125

125-
const html = this.html;
126-
126+
const html = this.isRemoteUrl
127+
? DOMPurify.sanitize(this.html, { ADD_TAGS: ['script'] })
128+
: this.html;
127129
this.html = this.template;
128-
129130
return html;
130131
}
131132

0 commit comments

Comments
 (0)