
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
react-sanitized-html
Advanced tools
A React component that will sanitize user-inputted HTML code, using the popular sanitize-html package
A React component that will sanitize user-inputted HTML code, using the popular sanitize-html
package.
This React component requires both react
and sanitize-html
to be installed to work. We marked both as peer dependency so you could use the version of React as it fit.
Run npm install react-sanitized-html sanitize-html --save
to install this package.
Because both
htmlparser2
anddomhandler
(dependencies ofsanitize-html
) requires ES2015 Property Accessors for shorthanded properties. Thus, this component cannot be used in IE8.
In
sanitize-html@1.14.1
, shorthands are not used. Thus, it is possible to build a workaround for IE8 by customizing both [htmlparser2
] and [domhandler
] without shorthands.
import SanitizedHTML from 'react-sanitized-html';
const HTML_FROM_USER = '<a href="http://bing.com/">Bing</a>';
ReactDOM.render(
<SanitizedHTML html={ HTML_FROM_USER } />,
document.getElementById('reactRoot')
);
It will output as:
<div>
<a href="http://bing.com/">Bing</a>
</div>
You can add sanitize-html
options as props. For example,
<SanitizedHTML
allowedAttributes={{ 'a': ['href'] }}
allowedTags={['a']}
html={ `<a href="http://bing.com/">Bing</a>` }
/>
You can find more options here.
To setup your development environment, after cloning the repository, run the following steps.
npm install react sanitize-html
npm install --only=development
Then run npm test
to run all tests.
Like us? Star us.
Found an issue? File us an issue.
[2.0.0] - 2017-12-08
FAQs
A React component that will sanitize user-inputted HTML code, using the popular sanitize-html package
The npm package react-sanitized-html receives a total of 6,075 weekly downloads. As such, react-sanitized-html popularity was classified as popular.
We found that react-sanitized-html demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.