@squiz/xaccel-xss-safe-content
TypeScript icon, indicating that this package has built-in type declarations

1.15.1-beta.0 • Public • Published

xss-safe-content

This package provides a React component that will escape dangerous HTML allowing WYSIWYG content to be safely used without possible XSS vulnerability injection vectors being added.

The component takes two defined props and spreads the others as HTML Attributes.

The remaining props are expected to be HTML Elements properties or Class Attributes.

Component Properties

Property Name Property description Property Type IsRequired
content The HTML content to be sanitized and rendered inside the component. string [x]
elementType The type of element to render the sanitized content in. Defaults to 'div'. string or React component

Props Example:

<XssSafeContent
  content='<script>alert("This is a test");</script>'
  elementType="section"
  className="customClass"
>
</XssSafeContent>

Usage:

Install the package by running: npm i @squiz/xaccel-xss-safe-content

import { XssSafeContent } from '@squiz/xaccel-xss-safe-content';

function SomeReactComponent({ content }) {
    return <XSSSafeContent content={content} elementType={'div'} />;
}

Readme

Keywords

none

Package Sidebar

Install

npm i @squiz/xaccel-xss-safe-content

Weekly Downloads

44

Version

1.15.1-beta.0

License

ISC

Unpacked Size

13.2 kB

Total Files

8

Last publish

Collaborators

  • squiz-npm-publish
  • cdloh
  • pcoshansquiz
  • tadams_squiz
  • abarnes_squiz
  • gsherwood
  • pnolland
  • chadszinow-squiz
  • deborahsherwood
  • griseborough
  • akarelia
  • sdanis
  • tbernardes
  • oliverneal
  • azakens
  • azenderowska.squiz
  • lnowak
  • mdobie
  • bmatters
  • ewyatt
  • lwright-sq
  • cupreti
  • jmatthew_squiz
  • wjarosz
  • bxwu
  • carlfoster
  • samort
  • yyang1029
  • squiz-dwebster
  • tsmyth
  • aqureshi-sqz
  • rainger_squiz
  • ajhawar
  • uqureshi
  • thomasgrob
  • avanschoor-squiz
  • ata-squiz
  • asharpe-squiz
  • aj12
  • squiz-lstephan
  • squiz-ncallahan
  • squiz-dschoen
  • squiz-ksilalahi
  • jpolgar-squiz
  • pkiriakou
  • rmcavoy-squiz
  • jchaware
  • lunowak-squiz
  • mnowakowski1
  • pantyporowicz-squiz
  • djarrott.squiz.net
  • dkaczmarek
  • lineenan
  • aaronchan1010
  • haleesquiz
  • rszarafinski
  • tmadden
  • gdemelloesilva.squiz
  • jwrobel
  • bpottier
  • hkapoor_squiz
  • jhendersonsquiz
  • joshsquiz
  • dstaskiewicz
  • cross-squiz
  • sjamesquiz
  • dheffernan
  • tmalinowski
  • riddhi_17
  • andrew-squiz
  • hadiroudaki