added unit testing, and started implementing unit tests...phew
This commit is contained in:
20
node_modules/he/LICENSE-MIT.txt
generated
vendored
Normal file
20
node_modules/he/LICENSE-MIT.txt
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
Copyright Mathias Bynens <https://mathiasbynens.be/>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
379
node_modules/he/README.md
generated
vendored
Normal file
379
node_modules/he/README.md
generated
vendored
Normal file
@ -0,0 +1,379 @@
|
||||
# he [](https://travis-ci.org/mathiasbynens/he) [](https://codecov.io/github/mathiasbynens/he?branch=master) [](https://gemnasium.com/mathiasbynens/he)
|
||||
|
||||
_he_ (for “HTML entities”) is a robust HTML entity encoder/decoder written in JavaScript. It supports [all standardized named character references as per HTML](https://html.spec.whatwg.org/multipage/syntax.html#named-character-references), handles [ambiguous ampersands](https://mathiasbynens.be/notes/ambiguous-ampersands) and other edge cases [just like a browser would](https://html.spec.whatwg.org/multipage/syntax.html#tokenizing-character-references), has an extensive test suite, and — contrary to many other JavaScript solutions — _he_ handles astral Unicode symbols just fine. [An online demo is available.](https://mothereff.in/html-entities)
|
||||
|
||||
## Installation
|
||||
|
||||
Via [npm](https://www.npmjs.com/):
|
||||
|
||||
```bash
|
||||
npm install he
|
||||
```
|
||||
|
||||
Via [Bower](http://bower.io/):
|
||||
|
||||
```bash
|
||||
bower install he
|
||||
```
|
||||
|
||||
Via [Component](https://github.com/component/component):
|
||||
|
||||
```bash
|
||||
component install mathiasbynens/he
|
||||
```
|
||||
|
||||
In a browser:
|
||||
|
||||
```html
|
||||
<script src="he.js"></script>
|
||||
```
|
||||
|
||||
In [Node.js](https://nodejs.org/), [io.js](https://iojs.org/), [Narwhal](http://narwhaljs.org/), and [RingoJS](http://ringojs.org/):
|
||||
|
||||
```js
|
||||
var he = require('he');
|
||||
```
|
||||
|
||||
In [Rhino](http://www.mozilla.org/rhino/):
|
||||
|
||||
```js
|
||||
load('he.js');
|
||||
```
|
||||
|
||||
Using an AMD loader like [RequireJS](http://requirejs.org/):
|
||||
|
||||
```js
|
||||
require(
|
||||
{
|
||||
'paths': {
|
||||
'he': 'path/to/he'
|
||||
}
|
||||
},
|
||||
['he'],
|
||||
function(he) {
|
||||
console.log(he);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `he.version`
|
||||
|
||||
A string representing the semantic version number.
|
||||
|
||||
### `he.encode(text, options)`
|
||||
|
||||
This function takes a string of text and encodes (by default) any symbols that aren’t printable ASCII symbols and `&`, `<`, `>`, `"`, `'`, and `` ` ``, replacing them with character references.
|
||||
|
||||
```js
|
||||
he.encode('foo © bar ≠ baz 𝌆 qux');
|
||||
// → 'foo © bar ≠ baz 𝌆 qux'
|
||||
```
|
||||
|
||||
As long as the input string contains [allowed code points](https://html.spec.whatwg.org/multipage/parsing.html#preprocessing-the-input-stream) only, the return value of this function is always valid HTML. Any [(invalid) code points that cannot be represented using a character reference](https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides) in the input are not encoded:
|
||||
|
||||
```js
|
||||
he.encode('foo \0 bar');
|
||||
// → 'foo \0 bar'
|
||||
```
|
||||
|
||||
However, enabling [the `strict` option](https://github.com/mathiasbynens/he#strict) causes invalid code points to throw an exception. With `strict` enabled, `he.encode` either throws (if the input contains invalid code points) or returns a string of valid HTML.
|
||||
|
||||
The `options` object is optional. It recognizes the following properties:
|
||||
|
||||
#### `useNamedReferences`
|
||||
|
||||
The default value for the `useNamedReferences` option is `false`. This means that `encode()` will not use any named character references (e.g. `©`) in the output — hexadecimal escapes (e.g. `©`) will be used instead. Set it to `true` to enable the use of named references.
|
||||
|
||||
**Note that if compatibility with older browsers is a concern, this option should remain disabled.**
|
||||
|
||||
```js
|
||||
// Using the global default setting (defaults to `false`):
|
||||
he.encode('foo © bar ≠ baz 𝌆 qux');
|
||||
// → 'foo © bar ≠ baz 𝌆 qux'
|
||||
|
||||
// Passing an `options` object to `encode`, to explicitly disallow named references:
|
||||
he.encode('foo © bar ≠ baz 𝌆 qux', {
|
||||
'useNamedReferences': false
|
||||
});
|
||||
// → 'foo © bar ≠ baz 𝌆 qux'
|
||||
|
||||
// Passing an `options` object to `encode`, to explicitly allow named references:
|
||||
he.encode('foo © bar ≠ baz 𝌆 qux', {
|
||||
'useNamedReferences': true
|
||||
});
|
||||
// → 'foo © bar ≠ baz 𝌆 qux'
|
||||
```
|
||||
|
||||
#### `decimal`
|
||||
|
||||
The default value for the `decimal` option is `false`. If the option is enabled, `encode` will generally use decimal escapes (e.g. `©`) rather than hexadecimal escapes (e.g. `©`). Beside of this replacement, the basic behavior remains the same when combined with other options. For example: if both options `useNamedReferences` and `decimal` are enabled, named references (e.g. `©`) are used over decimal escapes. HTML entities without a named reference are encoded using decimal escapes.
|
||||
|
||||
```js
|
||||
// Using the global default setting (defaults to `false`):
|
||||
he.encode('foo © bar ≠ baz 𝌆 qux');
|
||||
// → 'foo © bar ≠ baz 𝌆 qux'
|
||||
|
||||
// Passing an `options` object to `encode`, to explicitly disable decimal escapes:
|
||||
he.encode('foo © bar ≠ baz 𝌆 qux', {
|
||||
'decimal': false
|
||||
});
|
||||
// → 'foo © bar ≠ baz 𝌆 qux'
|
||||
|
||||
// Passing an `options` object to `encode`, to explicitly enable decimal escapes:
|
||||
he.encode('foo © bar ≠ baz 𝌆 qux', {
|
||||
'decimal': true
|
||||
});
|
||||
// → 'foo © bar ≠ baz 𝌆 qux'
|
||||
|
||||
// Passing an `options` object to `encode`, to explicitly allow named references and decimal escapes:
|
||||
he.encode('foo © bar ≠ baz 𝌆 qux', {
|
||||
'useNamedReferences': true,
|
||||
'decimal': true
|
||||
});
|
||||
// → 'foo © bar ≠ baz 𝌆 qux'
|
||||
```
|
||||
|
||||
#### `encodeEverything`
|
||||
|
||||
The default value for the `encodeEverything` option is `false`. This means that `encode()` will not use any character references for printable ASCII symbols that don’t need escaping. Set it to `true` to encode every symbol in the input string. When set to `true`, this option takes precedence over `allowUnsafeSymbols` (i.e. setting the latter to `true` in such a case has no effect).
|
||||
|
||||
```js
|
||||
// Using the global default setting (defaults to `false`):
|
||||
he.encode('foo © bar ≠ baz 𝌆 qux');
|
||||
// → 'foo © bar ≠ baz 𝌆 qux'
|
||||
|
||||
// Passing an `options` object to `encode`, to explicitly encode all symbols:
|
||||
he.encode('foo © bar ≠ baz 𝌆 qux', {
|
||||
'encodeEverything': true
|
||||
});
|
||||
// → 'foo © bar ≠ baz 𝌆 qux'
|
||||
|
||||
// This setting can be combined with the `useNamedReferences` option:
|
||||
he.encode('foo © bar ≠ baz 𝌆 qux', {
|
||||
'encodeEverything': true,
|
||||
'useNamedReferences': true
|
||||
});
|
||||
// → 'foo © bar ≠ baz 𝌆 qux'
|
||||
```
|
||||
|
||||
#### `strict`
|
||||
|
||||
The default value for the `strict` option is `false`. This means that `encode()` will encode any HTML text content you feed it, even if it contains any symbols that cause [parse errors](https://html.spec.whatwg.org/multipage/parsing.html#preprocessing-the-input-stream). To throw an error when such invalid HTML is encountered, set the `strict` option to `true`. This option makes it possible to use _he_ as part of HTML parsers and HTML validators.
|
||||
|
||||
```js
|
||||
// Using the global default setting (defaults to `false`, i.e. error-tolerant mode):
|
||||
he.encode('\x01');
|
||||
// → ''
|
||||
|
||||
// Passing an `options` object to `encode`, to explicitly enable error-tolerant mode:
|
||||
he.encode('\x01', {
|
||||
'strict': false
|
||||
});
|
||||
// → ''
|
||||
|
||||
// Passing an `options` object to `encode`, to explicitly enable strict mode:
|
||||
he.encode('\x01', {
|
||||
'strict': true
|
||||
});
|
||||
// → Parse error
|
||||
```
|
||||
|
||||
#### `allowUnsafeSymbols`
|
||||
|
||||
The default value for the `allowUnsafeSymbols` option is `false`. This means that characters that are unsafe for use in HTML content (`&`, `<`, `>`, `"`, `'`, and `` ` ``) will be encoded. When set to `true`, only non-ASCII characters will be encoded. If the `encodeEverything` option is set to `true`, this option will be ignored.
|
||||
|
||||
```js
|
||||
he.encode('foo © and & ampersand', {
|
||||
'allowUnsafeSymbols': true
|
||||
});
|
||||
// → 'foo © and & ampersand'
|
||||
```
|
||||
|
||||
#### Overriding default `encode` options globally
|
||||
|
||||
The global default setting can be overridden by modifying the `he.encode.options` object. This saves you from passing in an `options` object for every call to `encode` if you want to use the non-default setting.
|
||||
|
||||
```js
|
||||
// Read the global default setting:
|
||||
he.encode.options.useNamedReferences;
|
||||
// → `false` by default
|
||||
|
||||
// Override the global default setting:
|
||||
he.encode.options.useNamedReferences = true;
|
||||
|
||||
// Using the global default setting, which is now `true`:
|
||||
he.encode('foo © bar ≠ baz 𝌆 qux');
|
||||
// → 'foo © bar ≠ baz 𝌆 qux'
|
||||
```
|
||||
|
||||
### `he.decode(html, options)`
|
||||
|
||||
This function takes a string of HTML and decodes any named and numerical character references in it using [the algorithm described in section 12.2.4.69 of the HTML spec](https://html.spec.whatwg.org/multipage/syntax.html#tokenizing-character-references).
|
||||
|
||||
```js
|
||||
he.decode('foo © bar ≠ baz 𝌆 qux');
|
||||
// → 'foo © bar ≠ baz 𝌆 qux'
|
||||
```
|
||||
|
||||
The `options` object is optional. It recognizes the following properties:
|
||||
|
||||
#### `isAttributeValue`
|
||||
|
||||
The default value for the `isAttributeValue` option is `false`. This means that `decode()` will decode the string as if it were used in [a text context in an HTML document](https://html.spec.whatwg.org/multipage/syntax.html#data-state). HTML has different rules for [parsing character references in attribute values](https://html.spec.whatwg.org/multipage/syntax.html#character-reference-in-attribute-value-state) — set this option to `true` to treat the input string as if it were used as an attribute value.
|
||||
|
||||
```js
|
||||
// Using the global default setting (defaults to `false`, i.e. HTML text context):
|
||||
he.decode('foo&bar');
|
||||
// → 'foo&bar'
|
||||
|
||||
// Passing an `options` object to `decode`, to explicitly assume an HTML text context:
|
||||
he.decode('foo&bar', {
|
||||
'isAttributeValue': false
|
||||
});
|
||||
// → 'foo&bar'
|
||||
|
||||
// Passing an `options` object to `decode`, to explicitly assume an HTML attribute value context:
|
||||
he.decode('foo&bar', {
|
||||
'isAttributeValue': true
|
||||
});
|
||||
// → 'foo&bar'
|
||||
```
|
||||
|
||||
#### `strict`
|
||||
|
||||
The default value for the `strict` option is `false`. This means that `decode()` will decode any HTML text content you feed it, even if it contains any entities that cause [parse errors](https://html.spec.whatwg.org/multipage/syntax.html#tokenizing-character-references). To throw an error when such invalid HTML is encountered, set the `strict` option to `true`. This option makes it possible to use _he_ as part of HTML parsers and HTML validators.
|
||||
|
||||
```js
|
||||
// Using the global default setting (defaults to `false`, i.e. error-tolerant mode):
|
||||
he.decode('foo&bar');
|
||||
// → 'foo&bar'
|
||||
|
||||
// Passing an `options` object to `decode`, to explicitly enable error-tolerant mode:
|
||||
he.decode('foo&bar', {
|
||||
'strict': false
|
||||
});
|
||||
// → 'foo&bar'
|
||||
|
||||
// Passing an `options` object to `decode`, to explicitly enable strict mode:
|
||||
he.decode('foo&bar', {
|
||||
'strict': true
|
||||
});
|
||||
// → Parse error
|
||||
```
|
||||
|
||||
#### Overriding default `decode` options globally
|
||||
|
||||
The global default settings for the `decode` function can be overridden by modifying the `he.decode.options` object. This saves you from passing in an `options` object for every call to `decode` if you want to use a non-default setting.
|
||||
|
||||
```js
|
||||
// Read the global default setting:
|
||||
he.decode.options.isAttributeValue;
|
||||
// → `false` by default
|
||||
|
||||
// Override the global default setting:
|
||||
he.decode.options.isAttributeValue = true;
|
||||
|
||||
// Using the global default setting, which is now `true`:
|
||||
he.decode('foo&bar');
|
||||
// → 'foo&bar'
|
||||
```
|
||||
|
||||
### `he.escape(text)`
|
||||
|
||||
This function takes a string of text and escapes it for use in text contexts in XML or HTML documents. Only the following characters are escaped: `&`, `<`, `>`, `"`, `'`, and `` ` ``.
|
||||
|
||||
```js
|
||||
he.escape('<img src=\'x\' onerror="prompt(1)">');
|
||||
// → '<img src='x' onerror="prompt(1)">'
|
||||
```
|
||||
|
||||
### `he.unescape(html, options)`
|
||||
|
||||
`he.unescape` is an alias for `he.decode`. It takes a string of HTML and decodes any named and numerical character references in it.
|
||||
|
||||
### 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'
|
||||
föo ♥ bår 𝌆 baz
|
||||
|
||||
$ he --encode --use-named-refs 'föo ♥ bår 𝌆 baz'
|
||||
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
|
||||
|
||||
_he_ has been tested in at least:
|
||||
|
||||
* Chrome 27-50
|
||||
* Firefox 3-45
|
||||
* Safari 4-9
|
||||
* Opera 10-12, 15–37
|
||||
* IE 6–11
|
||||
* Edge
|
||||
* Narwhal 0.3.2
|
||||
* Node.js v0.10, v0.12, v4, v5
|
||||
* PhantomJS 1.9.0
|
||||
* Rhino 1.7RC4
|
||||
* RingoJS 0.8-0.11
|
||||
|
||||
## Unit tests & code coverage
|
||||
|
||||
After cloning this repository, run `npm install` to install the dependencies needed for he development and testing. You may want to install Istanbul _globally_ using `npm install istanbul -g`.
|
||||
|
||||
Once that’s done, you can run the unit tests in Node using `npm test` or `node tests/tests.js`. To run the tests in Rhino, Ringo, Narwhal, and web browsers as well, use `grunt test`.
|
||||
|
||||
To generate the code coverage report, use `grunt cover`.
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
Thanks to [Simon Pieters](https://simon.html5.org/) ([@zcorpan](https://twitter.com/zcorpan)) for the many suggestions.
|
||||
|
||||
## Author
|
||||
|
||||
| [](https://twitter.com/mathias "Follow @mathias on Twitter") |
|
||||
|---|
|
||||
| [Mathias Bynens](https://mathiasbynens.be/) |
|
||||
|
||||
## License
|
||||
|
||||
_he_ is available under the [MIT](https://mths.be/mit) license.
|
148
node_modules/he/bin/he
generated
vendored
Executable file
148
node_modules/he/bin/he
generated
vendored
Executable file
@ -0,0 +1,148 @@
|
||||
#!/usr/bin/env node
|
||||
(function() {
|
||||
|
||||
var fs = require('fs');
|
||||
var he = require('../he.js');
|
||||
var strings = process.argv.splice(2);
|
||||
var stdin = process.stdin;
|
||||
var data;
|
||||
var timeout;
|
||||
var action;
|
||||
var options = {};
|
||||
var log = console.log;
|
||||
|
||||
var main = function() {
|
||||
var option = strings[0];
|
||||
var count = 0;
|
||||
|
||||
if (/^(?:-h|--help|undefined)$/.test(option)) {
|
||||
log(
|
||||
'he v%s - https://mths.be/he',
|
||||
he.version
|
||||
);
|
||||
log([
|
||||
'\nUsage:\n',
|
||||
'\the [--escape] string',
|
||||
'\the [--encode] [--use-named-refs] [--everything] [--allow-unsafe] [--decimal] string',
|
||||
'\the [--decode] [--attribute] [--strict] string',
|
||||
'\the [-v | --version]',
|
||||
'\the [-h | --help]',
|
||||
'\nExamples:\n',
|
||||
'\the --escape \\<img\\ src\\=\\\'x\\\'\\ onerror\\=\\"prompt\\(1\\)\\"\\>',
|
||||
'\techo \'© 𝌆\' | he --decode'
|
||||
].join('\n'));
|
||||
return process.exit(option ? 0 : 1);
|
||||
}
|
||||
|
||||
if (/^(?:-v|--version)$/.test(option)) {
|
||||
log('v%s', he.version);
|
||||
return process.exit(0);
|
||||
}
|
||||
|
||||
strings.forEach(function(string) {
|
||||
// Process options
|
||||
if (string == '--escape') {
|
||||
action = 'escape';
|
||||
return;
|
||||
}
|
||||
if (string == '--encode') {
|
||||
action = 'encode';
|
||||
return;
|
||||
}
|
||||
if (string == '--use-named-refs') {
|
||||
action = 'encode';
|
||||
options.useNamedReferences = true;
|
||||
return;
|
||||
}
|
||||
if (string == '--everything') {
|
||||
action = 'encode';
|
||||
options.encodeEverything = true;
|
||||
return;
|
||||
}
|
||||
if (string == '--allow-unsafe') {
|
||||
action = 'encode';
|
||||
options.allowUnsafeSymbols = true;
|
||||
return;
|
||||
}
|
||||
if (string == '--decimal') {
|
||||
action = 'encode';
|
||||
options.decimal = true;
|
||||
return;
|
||||
}
|
||||
if (string == '--decode') {
|
||||
action = 'decode';
|
||||
return;
|
||||
}
|
||||
if (string == '--attribute') {
|
||||
action = 'decode';
|
||||
options.isAttributeValue = true;
|
||||
return;
|
||||
}
|
||||
if (string == '--strict') {
|
||||
action = 'decode';
|
||||
options.strict = true;
|
||||
return;
|
||||
}
|
||||
// Process string(s)
|
||||
var result;
|
||||
if (!action) {
|
||||
log('Error: he requires at least one option and a string argument.');
|
||||
log('Try `he --help` for more information.');
|
||||
return process.exit(1);
|
||||
}
|
||||
try {
|
||||
result = he[action](string, options);
|
||||
log(result);
|
||||
count++;
|
||||
} catch(error) {
|
||||
log(error.message + '\n');
|
||||
log('Error: failed to %s.', action);
|
||||
log('If you think this is a bug in he, please report it:');
|
||||
log('https://github.com/mathiasbynens/he/issues/new');
|
||||
log(
|
||||
'\nStack trace using he@%s:\n',
|
||||
he.version
|
||||
);
|
||||
log(error.stack);
|
||||
return process.exit(1);
|
||||
}
|
||||
});
|
||||
if (!count) {
|
||||
log('Error: he requires a string argument.');
|
||||
log('Try `he --help` for more information.');
|
||||
return process.exit(1);
|
||||
}
|
||||
// Return with exit status 0 outside of the `forEach` loop, in case
|
||||
// multiple strings were passed in.
|
||||
return process.exit(0);
|
||||
};
|
||||
|
||||
if (stdin.isTTY) {
|
||||
// handle shell arguments
|
||||
main();
|
||||
} else {
|
||||
// Either the script is called from within a non-TTY context, or `stdin`
|
||||
// content is being piped in.
|
||||
if (!process.stdout.isTTY) {
|
||||
// The script was called from a non-TTY context. This is a rather uncommon
|
||||
// use case we don’t actively support. However, we don’t want the script
|
||||
// to wait forever in such cases, so…
|
||||
timeout = setTimeout(function() {
|
||||
// …if no piped data arrived after a whole minute, handle shell
|
||||
// arguments instead.
|
||||
main();
|
||||
}, 60000);
|
||||
}
|
||||
data = '';
|
||||
stdin.on('data', function(chunk) {
|
||||
clearTimeout(timeout);
|
||||
data += chunk;
|
||||
});
|
||||
stdin.on('end', function() {
|
||||
strings.push(data.trim());
|
||||
main();
|
||||
});
|
||||
stdin.resume();
|
||||
}
|
||||
|
||||
}());
|
345
node_modules/he/he.js
generated
vendored
Normal file
345
node_modules/he/he.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
78
node_modules/he/man/he.1
generated
vendored
Normal file
78
node_modules/he/man/he.1
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
.Dd April 5, 2016
|
||||
.Dt he 1
|
||||
.Sh NAME
|
||||
.Nm he
|
||||
.Nd encode/decode HTML entities just like a browser would
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl -escape Ar string
|
||||
.br
|
||||
.Op Fl -encode Ar string
|
||||
.br
|
||||
.Op Fl -encode Fl -use-named-refs Fl -everything Fl -allow-unsafe Ar string
|
||||
.br
|
||||
.Op Fl -decode Ar string
|
||||
.br
|
||||
.Op Fl -decode Fl -attribute Ar string
|
||||
.br
|
||||
.Op Fl -decode Fl -strict Ar string
|
||||
.br
|
||||
.Op Fl v | -version
|
||||
.br
|
||||
.Op Fl h | -help
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
encodes/decodes HTML entities in strings just like a browser would.
|
||||
.Sh OPTIONS
|
||||
.Bl -ohang -offset
|
||||
.It Sy "--escape"
|
||||
Take a string of text and escape it for use in text contexts in XML or HTML documents. Only the following characters are escaped: `&`, `<`, `>`, `"`, and `'`.
|
||||
.It Sy "--encode"
|
||||
Take a string of text and encode 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 `+` 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.
|
||||
.It Sy "--encode --use-named-refs"
|
||||
Enable the use of named character references (like `©`) in the output. If compatibility with older browsers is a concern, don't use this option.
|
||||
.It Sy "--encode --everything"
|
||||
Encode every symbol in the input string, even safe printable ASCII symbols.
|
||||
.It Sy "--encode --allow-unsafe"
|
||||
Encode non-ASCII characters only. This leaves unsafe HTML/XML symbols like `&`, `<`, `>`, `"`, and `'` intact.
|
||||
.It Sy "--encode --decimal"
|
||||
Use decimal digits rather than hexadecimal digits for encoded character references, e.g. output `©` instead of `©`.
|
||||
.It Sy "--decode"
|
||||
Takes a string of HTML and decode any named and numerical character references in it using the algorithm described in the HTML spec.
|
||||
.It Sy "--decode --attribute"
|
||||
Parse the input as if it was an HTML attribute value rather than a string in an HTML text content.
|
||||
.It Sy "--decode --strict"
|
||||
Throw an error if an invalid character reference is encountered.
|
||||
.It Sy "-v, --version"
|
||||
Print he's version.
|
||||
.It Sy "-h, --help"
|
||||
Show the help screen.
|
||||
.El
|
||||
.Sh EXIT STATUS
|
||||
The
|
||||
.Nm he
|
||||
utility exits with one of the following values:
|
||||
.Pp
|
||||
.Bl -tag -width flag -compact
|
||||
.It Li 0
|
||||
.Nm
|
||||
did what it was instructed to do successfully; either it encoded/decoded the input and printed the result, or it printed the version or usage message.
|
||||
.It Li 1
|
||||
.Nm
|
||||
encountered an error.
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
.Bl -ohang -offset
|
||||
.It Sy "he --escape '<script>alert(1)</script>'"
|
||||
Print an escaped version of the given string that is safe for use in HTML text contexts, escaping only `&`, `<`, `>`, `"`, and `'`.
|
||||
.It Sy "he --decode '©𝌆'"
|
||||
Print the decoded version of the given HTML string.
|
||||
.It Sy "echo\ '©𝌆'\ |\ he --decode"
|
||||
Print the decoded version of the HTML string that gets piped in.
|
||||
.El
|
||||
.Sh BUGS
|
||||
he's bug tracker is located at <https://github.com/mathiasbynens/he/issues>.
|
||||
.Sh AUTHOR
|
||||
Mathias Bynens <https://mathiasbynens.be/>
|
||||
.Sh WWW
|
||||
<https://mths.be/he>
|
90
node_modules/he/package.json
generated
vendored
Normal file
90
node_modules/he/package.json
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
{
|
||||
"_from": "he@1.2.0",
|
||||
"_id": "he@1.2.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==",
|
||||
"_location": "/he",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "he@1.2.0",
|
||||
"name": "he",
|
||||
"escapedName": "he",
|
||||
"rawSpec": "1.2.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.2.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/mocha"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
|
||||
"_shasum": "84ae65fa7eafb165fddb61566ae14baf05664f0f",
|
||||
"_spec": "he@1.2.0",
|
||||
"_where": "/Users/josh.burman/Projects/braid/node_modules/mocha",
|
||||
"author": {
|
||||
"name": "Mathias Bynens",
|
||||
"url": "https://mathiasbynens.be/"
|
||||
},
|
||||
"bin": {
|
||||
"he": "bin/he"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/mathiasbynens/he/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "A robust HTML entities encoder/decoder with full Unicode support.",
|
||||
"devDependencies": {
|
||||
"codecov.io": "^0.1.6",
|
||||
"grunt": "^0.4.5",
|
||||
"grunt-cli": "^1.3.1",
|
||||
"grunt-shell": "^1.1.1",
|
||||
"grunt-template": "^0.2.3",
|
||||
"istanbul": "^0.4.2",
|
||||
"jsesc": "^1.0.0",
|
||||
"lodash": "^4.8.2",
|
||||
"qunit-extras": "^1.4.5",
|
||||
"qunitjs": "~1.11.0",
|
||||
"regenerate": "^1.2.1",
|
||||
"regexgen": "^1.3.0",
|
||||
"requirejs": "^2.1.22",
|
||||
"sort-object": "^3.0.2"
|
||||
},
|
||||
"directories": {
|
||||
"bin": "bin",
|
||||
"man": "man",
|
||||
"test": "tests"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE-MIT.txt",
|
||||
"he.js",
|
||||
"bin/",
|
||||
"man/"
|
||||
],
|
||||
"homepage": "https://mths.be/he",
|
||||
"keywords": [
|
||||
"string",
|
||||
"entities",
|
||||
"entity",
|
||||
"html",
|
||||
"encode",
|
||||
"decode",
|
||||
"unicode"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "he.js",
|
||||
"man": [
|
||||
"/Users/josh.burman/Projects/braid/node_modules/he/man/he.1"
|
||||
],
|
||||
"name": "he",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/mathiasbynens/he.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "grunt build",
|
||||
"test": "node tests/tests.js"
|
||||
},
|
||||
"version": "1.2.0"
|
||||
}
|
Reference in New Issue
Block a user