🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis
Socket
Book a DemoInstallSign in
Socket

xml-escape

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xml-escape

Escape XML

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
515K
2.45%
Maintainers
1
Weekly downloads
 
Created
Source

xml-escape

Escape XML in javascript (NodeJS)

npm install xml-escape

// Warning escape is a reserved word, so maybe best to use xmlescape for var name
var xmlescape = require('xml-escape');

xmlescape('"hello" \'world\' & false < true > -1');

// output
// '&quot;hello&quot; &apos;world&apos; &amp; false &lt; true &gt; -1'

// don't escape some characters
xmlescape('"hello" \'world\' & false < true > -1', '>"&')

// output
// '"hello" &apos;world&apos; & false &lt; true > -1'

There is also now an ignore function thanks to @jayflo

esc = require('./');

ignore = '"<&'
// note you should never ignore an &
output = esc('I am "<&not>" escaped', ignore)
console.log(output)

//I am "<&not&gt;" escaped

Bitdeli Badge

Keywords

Escape

FAQs

Package last updated on 14 Mar 2016

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