🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

form-text-sanitizer

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

form-text-sanitizer

Sanitize strings — expecting text — from html, svg, erb, and mustache expressions.

1.0.3
latest
Source
npm
Version published
Weekly downloads
11
120%
Maintainers
0
Weekly downloads
 
Created
Source

Form-Text-Sanitizer

form-text-sanitizer is a super-fast string sanitizer checking for HTML, SVG, ERB, and Mustache Expressions that may be contained inside input text. It is intended to prevent XSS Attacks.

Usage

Installation:

npm i form-text-sanitizer

Import the checkAndSanitizeString function to your JavaScript file:

import checkAndSanitizeString from "form-text-sanitizer";

Input the string you wish to sanitize and (optionally) destructure the response:

const { originalString, suggestedString, matches } = checkAndSanitizeString("My message: <Script>alert('XSS')</SCRIPT>End message.");

In the above example the response will be:

  {
    originalString: "My message: <script>alert('XSS')</SCRIPT>End message.",
    suggestedString: "My message: End message.",
    matches: ["<script>alert('XSS')</SCRIPT>"]
  }

originalString - User input string

suggestedString - Sanitized string

matches - Array of string(s) that are potentially malicious. This can be empty if no such strings are detected. In this case, suggestedString and originalString will be the same.

Keywords

xss

FAQs

Package last updated on 15 Mar 2025

Did you know?

Socket

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.

Install

Related posts