Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
strip-dom-tags
Advanced tools
Readme
Safely strip all DOM tags from a string to prevent XSS attacks
This module exposes a single functions, that strips a HTML string from tags. It uses the browser DOMParser API (https://caniuse.com/#search=domparser) internally to do the parsing and stripping. It has no dependencies.
You can whitelist different tags and attributes that are allowed, but javascript:
attribute values will always be stripped.
This module only works in the browser, it will always return the empty string if invoked server-side.
stripTags(html : string, whitelistedTags = [] : string[], whitelistedAttributes = [] : string[], visitNode?: (node: Node) : Node) : string
html
- The string to strip from HTML tags.whitelistedTags
- A list of HTML tags that are allowed, like a
and img
. This is case-insensitive. The default is no tags are allowed.whitelistedAttributes
- A list of HTML attributes that are allwed, like href
and src
. The passed attributes will be allowed on any tag that is whitelisted. So it is possible for a a
tag to get a src
attribute. Note that attribute values starting with javascript:
or containing \n
will always be stripped.visitNode
- A function that will be invoked on every resulting DOM node after it has been stripped. You can use this to remove invalid attribute, or add target
attribute to a
tags for example. You can also return a different node (maybe replace img
with picture
).The function returns a HTML string, that is stripped of all the listed tags.
FAQs
Safely strip DOM tags from a HTML string to prevent XSS attacks.
The npm package strip-dom-tags receives a total of 607 weekly downloads. As such, strip-dom-tags popularity was classified as not popular.
We found that strip-dom-tags demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.