Socket
Socket
Sign inDemoInstall

safe-text

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

safe-text

Simple safe text


Version published
Maintainers
1
Weekly downloads
27
decreased by-51.79%

Weekly downloads

Readme

Source

Safe-text

Simple javascript safe-text for node and browser.

keywords: Safe-text, Sanitize, HTML-entities, Strings, XSS


Install

NPM

$ npm install safe-text --save

API:

var safeText = require('safe-text');

safeText(String, IgnoreCases)

String

String that you want to safe.

e.g. '"><script>alert(1)</script>'

IgnoreCases (Optional)

The Array of cases you don't wan't to safe.

e.g. ['&', ')([]{}*#', 'emails']

  • emails is a embedded list of characters used in email addresses.
Embedded character lists
  • emails
  • urls
  • markdown

Example

var safeText = require('safe-text');

var str = '"><script>alert(1)</script><a href="http://example.tld/page.html">page</a>';
var ignore_cases = ['()/', 'urls'];

console.log(safeText(str, ignore_cases))
// &quot;&gt;&lt;script&gt;alert(1)&lt;/script&gt;&lt;a href=&quot;http://example.tld/page.html&quot;&gt;page&lt;/a&gt;

Keywords

FAQs

Last updated on 22 May 2016

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc