Skip to content

Commit

Permalink
Merge pull request #368 from SolidOS/sanitize
Browse files Browse the repository at this point in the history
sanitize markdown
  • Loading branch information
bourgeoa authored Mar 9, 2023
2 parents 974f830 + 39483f7 commit 282a8fe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"activitystreams-pane": "0.6.10",
"chat-pane": "2.4.22",
"contacts-pane": "^2.6.9",
"dompurify": "^3.0.1",
"folder-pane": "^2.4.24",
"issue-pane": "2.4.16",
"marked": "^4.2.12",
Expand Down
6 changes: 4 additions & 2 deletions src/humanReadablePane.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { icons, ns } from 'solid-ui'
import { Util } from 'rdflib'
import { marked } from 'marked'
import * as DOMPurify from 'dompurify'

const humanReadablePane = {
icon: icons.originalIconBase + 'tango/22-text-x-generic.png',
Expand Down Expand Up @@ -76,7 +77,7 @@ const humanReadablePane = {
const cts = kb.fetcher.getHeader(subject.doc(), 'content-type')
const ct = cts ? cts[0] : null
if (ct) {
console.log('humanReadablePane: c-t:' + ct)
// console.log('humanReadablePane: c-t:' + ct)
} else {
console.log('humanReadablePane: unknown content-type?')
}
Expand All @@ -92,7 +93,8 @@ const humanReadablePane = {
const markdownText = response.responseText
const lines = Math.min(30, markdownText.split(/\n/).length + 5)
const res = marked.parse(markdownText)
frame.innerHTML = res
const clean = DOMPurify.sanitize(res)
frame.innerHTML = clean
frame.setAttribute('class', 'doc')
frame.setAttribute('style', `border: 1px solid; padding: 1em; height: ${lines}em; width: 800px; resize: both; overflow: auto;`)
})
Expand Down

0 comments on commit 282a8fe

Please sign in to comment.