Modules@robinpath/sanitize

@robinpath/sanitize

0.1.0Public

Input sanitization utilities for security: HTML escaping, XSS prevention, SQL escaping, filename and path sanitization, URL cleaning, and more

@robinpath/sanitize

Input sanitization utilities for security: HTML escaping, XSS prevention, SQL escaping, filename and path sanitization, URL cleaning, and more

Category Functions Auth License

Why use this module?

The sanitize module lets you:

  • Strip or escape HTML tags from input
  • Remove XSS attack vectors from input
  • Escape SQL special characters to prevent injection
  • Escape special regex characters in a string
  • Sanitize a string for safe use as a filename

All functions are callable directly from RobinPath scripts with a simple, consistent API.

Installation

npm install @robinpath/sanitize

Quick Start

No credentials needed — start using it right away:

sanitize.xss

Available Functions

FunctionDescription
sanitize.htmlStrip or escape HTML tags from input
sanitize.xssRemove XSS attack vectors from input
sanitize.sqlEscape SQL special characters to prevent injection
sanitize.regexEscape special regex characters in a string
sanitize.filenameSanitize a string for safe use as a filename
sanitize.pathPrevent path traversal attacks by sanitizing a file path
sanitize.urlSanitize a URL, stripping dangerous protocols like javascript:
sanitize.emailNormalize an email address (lowercase, remove dots/plus aliases for Gmail)
sanitize.stripTagsRemove all HTML tags from a string, optionally allowing specific tags
sanitize.escapeHtmlEscape HTML special characters: & < > " '
sanitize.unescapeHtmlUnescape HTML entities back to their original characters
sanitize.trimDeep trim all string values within an object, array, or string
sanitize.truncateTruncate a string to a maximum length with a suffix
sanitize.alphanumericStrip all non-alphanumeric characters from a string
sanitize.slugSanitize a string into a URL-safe slug

Examples

Remove XSS attack vectors from input

sanitize.xss

Escape SQL special characters to prevent injection

sanitize.sql

Escape special regex characters in a string

sanitize.regex

Integration with RobinPath

import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/sanitize";

const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);

const result = await rp.executeScript(`
  sanitize.xss
`);

Full API Reference

See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.

Related Modules

License

MIT

Versions (1)

VersionTagPublished
0.1.0latestyesterday
Install
$ robinpath install @robinpath/sanitize
Version0.1.0
LicenseMIT
Unpacked Size5.6 KB
Versions1
Weekly Downloads0
Total Downloads0
Stars0
Last Publishyesterday
Createdyesterday

Category

utilities