Skip to content

Commit

Permalink
fix: use dompurify for html sanitization
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
  • Loading branch information
aonnikov committed Sep 13, 2024
1 parent fc8564d commit cdcd62c
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 8 deletions.
30 changes: 26 additions & 4 deletions common/config/rush/pnpm-lock.yaml

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

2 changes: 2 additions & 0 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"prettier": "^3.1.0",
"typescript": "^5.3.3",
"@types/jest": "^29.5.5",
"@types/dompurify": "^3.0.5",
"jest": "^29.7.0",
"ts-jest": "^29.1.1",
"svelte-eslint-parser": "^0.33.1"
Expand All @@ -47,6 +48,7 @@
"emoji-regex": "^10.1.0",
"date-fns": "^2.30.0",
"date-fns-tz": "^2.0.0",
"dompurify": "^3.1.6",
"@hcengineering/analytics": "^0.6.0"
},
"repository": "https://github.com/hcenginneing/anticrm",
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export { default as DatePresenter } from './components/calendar/DatePresenter.sv
export { default as DueDatePresenter } from './components/calendar/DueDatePresenter.svelte'
export { default as DateTimePresenter } from './components/calendar/DateTimePresenter.svelte'
export { default as TimeInputBox } from './components/calendar/TimeInputBox.svelte'
export { default as Html } from './components/Html.svelte'
export { default as StylishEdit } from './components/StylishEdit.svelte'
export { default as Grid } from './components/Grid.svelte'
export { default as Row } from './components/Row.svelte'
Expand Down
4 changes: 3 additions & 1 deletion plugins/diffview-resources/src/components/Highlight.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// limitations under the License.
-->
<script lang="ts">
import { Html } from '@hcengineering/ui'
import { highlightText } from '../highlight'
export let value: string
Expand All @@ -21,4 +23,4 @@
$: highlighted = highlightText(value, { language })
</script>

{@html highlighted}
<Html value={highlighted} />
4 changes: 1 addition & 3 deletions plugins/diffview-resources/src/highlight/highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ export function highlightText (text: string, options: HighlightOptions): string
const { language } = options
const validLanguage = language !== undefined && hljs.getLanguage(language) !== undefined

const { value: highlighted } = validLanguage
? hljs.highlight(text, { language })
: hljs.highlightAuto(text)
const { value: highlighted } = validLanguage ? hljs.highlight(text, { language }) : hljs.highlightAuto(text)

return normalizeHighlightTags(highlighted)
}
Expand Down

0 comments on commit cdcd62c

Please sign in to comment.