
Security News
curl Shuts Down Bug Bounty Program After Flood of AI Slop Reports
A surge of AI-generated vulnerability reports has pushed open source maintainers to rethink bug bounties and tighten security disclosure processes.
sanitize-input
Advanced tools
Simple, declarative interface to scrub user inputs with the Sanitizer Web API.
The Sanitizer Web API is a tool which allows developers to take untrusted strings of HTML, and sanitize them for safe insertion into a document’s DOM. sanitize-input simplifies window.Sanitizer's API, removing programmatic access to DOM in favor of a more declarative interface useful for frontend frameworks.
The Sanitizer Web API is currently in development, try to use Chrome Canary with chrome://flags/#enable-experimental-web-platform-features enabled, or Firefox Nightly with dom.security.sanitizer.enabled set to true.
npm install sanitize-input
Invoking the default export from sanitize-input will return a function that has a closed over reference to a single instance of window.Sanitizer. This returned function (this.sanitize in the examples) behaves in two ways. Given a string, it will return a sanitized string. Given an event handler, Sanitize will wrap the function, creating a sanitizedValue property on event.target.
import Sanitizer from 'sanitize-input';
class App extends React.Component {
constructor() {
this.state = { inputText: 'none' };
this.onChange = this.onChange.bind(this);
// creates one reusable instance of window.Sanitizer
this.sanitize = Sanitizer();
}
onChange(e) {
this.setState({ inputText: this.sanitize(e.target.value) });
}
render() {
return (
<div>
<input type="text" onChange={this.onChange} />
<p>{this.state.inputText}</p>
</div>
);
}
}
e.target.sanitizedValueimport Sanitizer from 'sanitize-input';
class App extends React.Component {
constructor() {
this.state = { inputText: 'none' };
this.onChange = this.onChange.bind(this);
// creates one reusable instance of window.Sanitizer
this.sanitize = Sanitizer();
}
onChange(e) {
this.setState({ inputText: e.target.sanitizedValue });
}
render() {
return (
<div>
<input type="text" onChange={this.sanitize(this.onChange)} />
<p>{this.state.inputText}</p>
</div>
);
}
}
MIT
FAQs
sanitize input elements with sanitizer web api
We found that sanitize-input 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
A surge of AI-generated vulnerability reports has pushed open source maintainers to rethink bug bounties and tighten security disclosure processes.

Product
Scan results now load faster and remain consistent over time, with stable URLs and on-demand rescans for fresh security data.

Product
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.