Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xml-sanitize-string

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xml-sanitize-string

This module replaces characters that are not valid in XML in a string with XML/HTML character entities (and vice versa).

  • 1.0.4
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

xml-sanitize-string

This module replaces characters that are not valid in XML in a string with XML/HTML character entities (and vice versa).

Emoji, and many other characters are not valid in XML, and may cause problems if they sneak into your XML. This small module has two methods to sanitize (escape invalid characters) a string, and to unescape a string.

Installation & usage

Install xml-sanitize-string via NPM:

npm install xml-sanitize-string

In Node:

var xmlSanitizeString = require('xml-sanitize-string');

// Sanatize a string for use in XML by escaping invalid characters to XML character entities.
xmlSanitizeString.escape('Some 👉 invalid 💻 characters 🎒')
// Some &#1f449; invalid &#1f4bb; characters &#1f392;

// Unescape a string containing XML character entities to unicode characters
xmlSanitizeString.unescape('Some &#1f449; invalid &#1f4bb; characters &#1f392;')
// Some 👉 invalid 💻 characters 🎒

About

xml-sanitize-string was built by Nick Drewe to deal with user searches on searchmy.bio that may contain emoji, or other characters that are invalid in XML.

Keywords

FAQs

Package last updated on 07 Aug 2018

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc