fix(plugins): avoid xss for the injected readme html content

This commit is contained in:
charlie
2025-04-25 12:28:59 +08:00
parent 5efaf84507
commit 4cdf49aedd
3 changed files with 4 additions and 2 deletions

View File

@@ -72,6 +72,7 @@ const common = {
'node_modules/react-dom/umd/react-dom.production.min.js',
'node_modules/react-dom/umd/react-dom.development.js',
'node_modules/prop-types/prop-types.min.js',
'node_modules/dompurify/dist/purify.js',
]).pipe(gulp.dest(path.join(outputPath, 'js'))),
() => gulp.src([
'node_modules/@tabler/icons-react/dist/umd/tabler-icons-react.min.js',

View File

@@ -69,6 +69,7 @@
<body>
<div id="app"></div>
<script src="./js/marked.min.js"></script>
<script src="./js/purify.js"></script>
<script>
;(async function () {
const app = document.getElementById('app')
@@ -131,7 +132,7 @@
}
content = marked.parse(content).replace('src="./', `src="${fixLink('')}`)
setContent(content)
setContent(DOMPurify.sanitize(content))
}
// load default

View File

@@ -202,7 +202,7 @@
(rum/defc remote-readme-display
[{: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)]
[:iframe.lsp-frame-readme {:src src}]))