Socket
Socket
Sign inDemoInstall

he

Package Overview
Dependencies
0
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.1 to 0.3.2

bin/he

18

package.json
{
"name": "he",
"version": "0.3.1",
"version": "0.3.2",
"description": "A robust HTML entities encoder/decoder with full Unicode support.",
"homepage": "http://mths.be/he",
"main": "he.js",
"bin": "bin/he",
"man": "man/he.1",
"keywords": [

@@ -33,2 +35,8 @@ "string",

},
"files": [
"LICENSE-MIT.txt",
"he.js",
"bin/",
"man/"
],
"directories": {

@@ -43,5 +51,6 @@ "test": "tests"

"grunt": "~0.4.1",
"grunt-shell": "~0.3.0",
"grunt-shell": "~0.3.1",
"grunt-template": "~0.2.0",
"istanbul": "~0.1.37",
"istanbul": "~0.1.42",
"jsesc": "~0.3.0",
"lodash": "~1.3.1",

@@ -51,5 +60,4 @@ "qunit-clib": "~1.3.0",

"regenerate": "~0.5.2",
"requirejs": "~2.1.6",
"string-escape": "~0.2.2"
"requirejs": "~2.1.8"
}
}

@@ -67,3 +67,3 @@ # he [![Build status](https://travis-ci.org/mathiasbynens/he.png?branch=master)](https://travis-ci.org/mathiasbynens/he) [![Dependency status](https://gemnasium.com/mathiasbynens/he.png)](https://gemnasium.com/mathiasbynens/he)

This function takes a string of text and encodes any symbols that aren’t printable ASCII symbols and that can be replaced with named character references. For example, it would turn `©` into `©`, but it wouldn’t turn `+` into `+` since there is no point in doing so. Additionally, it replaces any remaining non-ASCII symbols with a hexadecimal escape sequence (e.g. `𝌆`). The return value of this function is always valid HTML.
This function takes a string of text and encodes any symbols that aren’t printable ASCII symbols and that can be replaced with character references. For example, it would turn `©` into `©`, but it wouldn’t turn `+` into `+` or `+` since there is no point in doing so. Additionally, it replaces any remaining non-ASCII symbols with a hexadecimal escape sequence (e.g. `𝌆`). The return value of this function is always valid HTML.

@@ -123,3 +123,3 @@ ```js

```js
he.encode('foo © bar ≠ baz 𝌆 qux');
he.decode('foo © bar ≠ baz 𝌆 qux');
// → 'foo © bar ≠ baz 𝌆 qux'

@@ -140,3 +140,3 @@ ```

// Passing an `options` object to `decode`, to explicitly assume an HTML text context:
he.encode('foo&ampbar', {
he.decode('foo&ampbar', {
'isAttributeValue': false

@@ -146,4 +146,4 @@ });

// Passing an `options` object to `encode`, to explicitly assume an HTML attribute value context:
he.encode('foo&ampbar', {
// Passing an `options` object to `decode`, to explicitly assume an HTML attribute value context:
he.decode('foo&ampbar', {
'isAttributeValue': true

@@ -206,2 +206,45 @@ });

### Using the `he` binary
To use the `he` binary in your shell, simply install he globally using npm:
```bash
npm install -g he
```
After that you will be able to encode/decode HTML entities from the command line:
```bash
$ he --encode 'föo ♥ bår 𝌆 baz'
$ he --decode 'föo ♥ bår 𝌆 baz'
föo ♥ bår 𝌆 baz
```
Read a local text file, encode it for use in an HTML text context, and save the result to a new file:
```bash
$ he --encode < foo.txt > foo-escaped.html
```
Or do the same with an online text file:
```bash
$ curl -sL "http://git.io/HnfEaw" | he --encode > escaped.html
```
Or, the opposite — read a local file containing a snippet of HTML in a text context, decode it back to plain text, and save the result to a new file:
```bash
$ he --decode < foo-escaped.html > foo.txt
```
Or do the same with an online HTML snippet:
```bash
$ curl -sL "http://git.io/HnfEaw" | he --decode > decoded.txt
```
See `he --help` for the full list of options.
## Support

@@ -208,0 +251,0 @@

Sorry, the diff of this file is too big to display

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