mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 22:25:01 +00:00
fix(plugins): avoid xss for the injected readme html content
This commit is contained in:
@@ -72,6 +72,7 @@ const common = {
|
|||||||
'node_modules/react-dom/umd/react-dom.production.min.js',
|
'node_modules/react-dom/umd/react-dom.production.min.js',
|
||||||
'node_modules/react-dom/umd/react-dom.development.js',
|
'node_modules/react-dom/umd/react-dom.development.js',
|
||||||
'node_modules/prop-types/prop-types.min.js',
|
'node_modules/prop-types/prop-types.min.js',
|
||||||
|
'node_modules/dompurify/dist/purify.js',
|
||||||
]).pipe(gulp.dest(path.join(outputPath, 'js'))),
|
]).pipe(gulp.dest(path.join(outputPath, 'js'))),
|
||||||
() => gulp.src([
|
() => gulp.src([
|
||||||
'node_modules/@tabler/icons-react/dist/umd/tabler-icons-react.min.js',
|
'node_modules/@tabler/icons-react/dist/umd/tabler-icons-react.min.js',
|
||||||
|
|||||||
@@ -69,6 +69,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script src="./js/marked.min.js"></script>
|
<script src="./js/marked.min.js"></script>
|
||||||
|
<script src="./js/purify.js"></script>
|
||||||
<script>
|
<script>
|
||||||
;(async function () {
|
;(async function () {
|
||||||
const app = document.getElementById('app')
|
const app = document.getElementById('app')
|
||||||
@@ -131,7 +132,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
content = marked.parse(content).replace('src="./', `src="${fixLink('')}`)
|
content = marked.parse(content).replace('src="./', `src="${fixLink('')}`)
|
||||||
setContent(content)
|
setContent(DOMPurify.sanitize(content))
|
||||||
}
|
}
|
||||||
|
|
||||||
// load default
|
// load default
|
||||||
|
|||||||
@@ -202,7 +202,7 @@
|
|||||||
|
|
||||||
(rum/defc remote-readme-display
|
(rum/defc remote-readme-display
|
||||||
[{:keys [repo]} _content]
|
[{:keys [repo]} _content]
|
||||||
(let [src (str (if (string/includes? js/location.href "logseq")
|
(let [src (str (if (string/includes? js/location.host "logseq")
|
||||||
"./static/" "./") "marketplace.html?repo=" repo)]
|
"./static/" "./") "marketplace.html?repo=" repo)]
|
||||||
[:iframe.lsp-frame-readme {:src src}]))
|
[:iframe.lsp-frame-readme {:src src}]))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user