Socket
Socket
Sign inDemoInstall

escape-html

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    escape-html

Escape HTML entities


Version published
Weekly downloads
25M
decreased by-18.79%
Maintainers
1
Install size
1.66 kB
Created
Weekly downloads
 

Package description

What is escape-html?

The escape-html package is designed to provide a simple and efficient way to escape HTML entities in strings. This is particularly useful to prevent XSS (Cross-Site Scripting) attacks by sanitizing user input or any data that might be dynamically inserted into HTML documents. The primary functionality of this package is to convert characters like '<', '>', '&', '"', and "'" into their corresponding HTML entities, making the output safe to include in HTML content.

What are escape-html's main functionalities?

Escaping HTML entities

This feature allows the conversion of potentially dangerous characters into their safe HTML entity equivalents. The provided code sample demonstrates how to use the escape-html package to escape a string that contains HTML and JavaScript, which could be harmful if rendered directly in a web page.

"const escapeHtml = require('escape-html');\nconst unsafeString = '<script>alert(\"XSS\")</script>';\nconst safeString = escapeHtml(unsafeString);\nconsole.log(safeString); // Output: &lt;script&gt;alert(&quot;XSS&quot;)&lt;/script&gt;"

Other packages similar to escape-html

Readme

Source

escape-html

Escape HTML entities

Example

var escape = require('escape-html');
escape(str);

License

MIT

Keywords

FAQs

Last updated on 20 Aug 2012

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