How to use the dompurify.default function in dompurify

To help you get started, we’ve selected a few dompurify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Tarnadas / net64plus / src / renderer / utils / chat.util.ts View on Github external
import * as marked from 'marked'
import { emojify } from 'node-emoji'

import { store } from '..'
import { MAX_LENGTH_USERNAME } from '../components/views/SettingsView'
import { addGlobalChatMessage, clearGlobalChatMessages } from '../actions/chat'
import { ChatMessage } from '../../models/State.model'

const { sanitize } = require('dompurify').default

export function addGlobalMessage (message: string, username: string, isTrusted = false) {
  const date = new Date()
  const sanitizedMessage = isTrusted
    ? sanitize(emojify(marked(message)))
    : emojify(message)
  const chatMessage: ChatMessage = {
    key: date.getUTCMilliseconds(),
    time: `${String(date.getHours()).padStart(2, '00')}:${String(date.getMinutes()).padStart(2, '00')}:${String(date.getSeconds()).padStart(2, '00')}`,
    message: sanitizedMessage,
    username: sanitize(username).substr(0, MAX_LENGTH_USERNAME),
    isTrusted
  }
  store.dispatch(addGlobalChatMessage(chatMessage))
}
github Tarnadas / net64plus / src / renderer / components / panels / ServerPanel.tsx View on Github external
import * as React from 'react'
import { Dispatch } from 'redux'
import { connect } from 'react-redux'
import { shell } from 'electron'
import * as marked from 'marked'
import { emojify } from 'node-emoji'

import { connector } from '../..'
import { SMMButton } from '../buttons/SMMButton'
import { WarningPanel } from '../panels/WarningPanel'
import { disconnect, setConnectionError } from '../../actions/connection'
import { State } from '../../../models/State.model'
import { Server } from '../../../models/Server.model'
import { IPlayer, GameModeType } from '../../../../proto/ServerClientMessage'

const { sanitize } = require('dompurify').default

interface ServerPanelProps {
  dispatch: Dispatch
  server: Server
  username: string
  characterId: number
  connectionError: string
  onConnect?: () => void
  isConnected?: boolean
}

interface ServerPanelState {
  display: boolean
  displayDescription: boolean
  warning: string
}

dompurify

DOMPurify is a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG. It's written in JavaScript and works in all modern browsers (Safari, Opera (15+), Internet Explorer (10+), Firefox and Chrome - as well as almost anything else usin

(MPL-2.0 OR Apache-2.0)
Latest version published 1 month ago

Package Health Score

88 / 100
Full package analysis