Socket
Socket
Sign inDemoInstall

entities

Package Overview
Dependencies
0
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.3.0 to 4.3.1

18

lib/decode.d.ts

@@ -12,5 +12,23 @@ import htmlDecodeTree from "./generated/decode-data-html.js";

export declare function determineBranch(decodeTree: Uint16Array, current: number, nodeIdx: number, char: number): number;
/**
* Decodes an HTML string, allowing for entities not terminated by a semi-colon.
*
* @param str The string to decode.
* @returns The decoded string.
*/
export declare function decodeHTML(str: string): string;
/**
* Decodes an HTML string, requiring all entities to be terminated by a semi-colon.
*
* @param str The string to decode.
* @returns The decoded string.
*/
export declare function decodeHTMLStrict(str: string): string;
/**
* Decodes an XML string, requiring all entities to be terminated by a semi-colon.
*
* @param str The string to decode.
* @returns The decoded string.
*/
export declare function decodeXML(str: string): string;
//# sourceMappingURL=decode.d.ts.map

20

lib/decode.js

@@ -123,3 +123,3 @@ "use strict";

var value = char - jumpOffset;
return value < 0 || value > branchCount
return value < 0 || value >= branchCount
? -1

@@ -150,2 +150,8 @@ : decodeTree[nodeIdx + value] - 1;

var xmlDecoder = getDecoder(decode_data_xml_js_1.default);
/**
* Decodes an HTML string, allowing for entities not terminated by a semi-colon.
*
* @param str The string to decode.
* @returns The decoded string.
*/
function decodeHTML(str) {

@@ -155,2 +161,8 @@ return htmlDecoder(str, false);

exports.decodeHTML = decodeHTML;
/**
* Decodes an HTML string, requiring all entities to be terminated by a semi-colon.
*
* @param str The string to decode.
* @returns The decoded string.
*/
function decodeHTMLStrict(str) {

@@ -160,2 +172,8 @@ return htmlDecoder(str, true);

exports.decodeHTMLStrict = decodeHTMLStrict;
/**
* Decodes an XML string, requiring all entities to be terminated by a semi-colon.
*
* @param str The string to decode.
* @returns The decoded string.
*/
function decodeXML(str) {

@@ -162,0 +180,0 @@ return xmlDecoder(str, true);

20

lib/encode.d.ts
/**
* Encodes all entities and non-ASCII characters in the input.
* Encodes all characters in the input using HTML entities. This includes
* characters that are valid ASCII characters in HTML documents, such as `#`.
*
* This includes characters that are valid ASCII characters in HTML documents.
* For example `#` will be encoded as `&num;`. To get a more compact output,
* consider using the `encodeNonAsciiHTML` function.
* To get a more compact output, consider using the `encodeNonAsciiHTML`
* function, which will only encode characters that are not valid in HTML
* documents, as well as non-ASCII characters.
*
* If a character has no equivalent entity, a
* numeric hexadecimal reference (eg. `&#xfc;`) will be used.
* If a character has no equivalent entity, a numeric hexadecimal reference
* (eg. `&#xfc;`) will be used.
*/

@@ -14,8 +15,9 @@ export declare function encodeHTML(data: string): string;

* Encodes all non-ASCII characters, as well as characters not valid in HTML
* documents using HTML entities.
* documents using HTML entities. This function will not encode characters that
* are valid in HTML documents, such as `#`.
*
* If a character has no equivalent entity, a
* numeric hexadecimal reference (eg. `&#xfc;`) will be used.
* If a character has no equivalent entity, a numeric hexadecimal reference
* (eg. `&#xfc;`) will be used.
*/
export declare function encodeNonAsciiHTML(data: string): string;
//# sourceMappingURL=encode.d.ts.map

@@ -11,10 +11,11 @@ "use strict";

/**
* Encodes all entities and non-ASCII characters in the input.
* Encodes all characters in the input using HTML entities. This includes
* characters that are valid ASCII characters in HTML documents, such as `#`.
*
* This includes characters that are valid ASCII characters in HTML documents.
* For example `#` will be encoded as `&num;`. To get a more compact output,
* consider using the `encodeNonAsciiHTML` function.
* To get a more compact output, consider using the `encodeNonAsciiHTML`
* function, which will only encode characters that are not valid in HTML
* documents, as well as non-ASCII characters.
*
* If a character has no equivalent entity, a
* numeric hexadecimal reference (eg. `&#xfc;`) will be used.
* If a character has no equivalent entity, a numeric hexadecimal reference
* (eg. `&#xfc;`) will be used.
*/

@@ -27,6 +28,7 @@ function encodeHTML(data) {

* Encodes all non-ASCII characters, as well as characters not valid in HTML
* documents using HTML entities.
* documents using HTML entities. This function will not encode characters that
* are valid in HTML documents, such as `#`.
*
* If a character has no equivalent entity, a
* numeric hexadecimal reference (eg. `&#xfc;`) will be used.
* If a character has no equivalent entity, a numeric hexadecimal reference
* (eg. `&#xfc;`) will be used.
*/

@@ -33,0 +35,0 @@ function encodeNonAsciiHTML(data) {

@@ -12,5 +12,23 @@ import htmlDecodeTree from "./generated/decode-data-html.js";

export declare function determineBranch(decodeTree: Uint16Array, current: number, nodeIdx: number, char: number): number;
/**
* Decodes an HTML string, allowing for entities not terminated by a semi-colon.
*
* @param str The string to decode.
* @returns The decoded string.
*/
export declare function decodeHTML(str: string): string;
/**
* Decodes an HTML string, requiring all entities to be terminated by a semi-colon.
*
* @param str The string to decode.
* @returns The decoded string.
*/
export declare function decodeHTMLStrict(str: string): string;
/**
* Decodes an XML string, requiring all entities to be terminated by a semi-colon.
*
* @param str The string to decode.
* @returns The decoded string.
*/
export declare function decodeXML(str: string): string;
//# sourceMappingURL=decode.d.ts.map

@@ -114,3 +114,3 @@ import htmlDecodeTree from "./generated/decode-data-html.js";

const value = char - jumpOffset;
return value < 0 || value > branchCount
return value < 0 || value >= branchCount
? -1

@@ -140,8 +140,26 @@ : decodeTree[nodeIdx + value] - 1;

const xmlDecoder = getDecoder(xmlDecodeTree);
/**
* Decodes an HTML string, allowing for entities not terminated by a semi-colon.
*
* @param str The string to decode.
* @returns The decoded string.
*/
export function decodeHTML(str) {
return htmlDecoder(str, false);
}
/**
* Decodes an HTML string, requiring all entities to be terminated by a semi-colon.
*
* @param str The string to decode.
* @returns The decoded string.
*/
export function decodeHTMLStrict(str) {
return htmlDecoder(str, true);
}
/**
* Decodes an XML string, requiring all entities to be terminated by a semi-colon.
*
* @param str The string to decode.
* @returns The decoded string.
*/
export function decodeXML(str) {

@@ -148,0 +166,0 @@ return xmlDecoder(str, true);

/**
* Encodes all entities and non-ASCII characters in the input.
* Encodes all characters in the input using HTML entities. This includes
* characters that are valid ASCII characters in HTML documents, such as `#`.
*
* This includes characters that are valid ASCII characters in HTML documents.
* For example `#` will be encoded as `&num;`. To get a more compact output,
* consider using the `encodeNonAsciiHTML` function.
* To get a more compact output, consider using the `encodeNonAsciiHTML`
* function, which will only encode characters that are not valid in HTML
* documents, as well as non-ASCII characters.
*
* If a character has no equivalent entity, a
* numeric hexadecimal reference (eg. `&#xfc;`) will be used.
* If a character has no equivalent entity, a numeric hexadecimal reference
* (eg. `&#xfc;`) will be used.
*/

@@ -14,8 +15,9 @@ export declare function encodeHTML(data: string): string;

* Encodes all non-ASCII characters, as well as characters not valid in HTML
* documents using HTML entities.
* documents using HTML entities. This function will not encode characters that
* are valid in HTML documents, such as `#`.
*
* If a character has no equivalent entity, a
* numeric hexadecimal reference (eg. `&#xfc;`) will be used.
* If a character has no equivalent entity, a numeric hexadecimal reference
* (eg. `&#xfc;`) will be used.
*/
export declare function encodeNonAsciiHTML(data: string): string;
//# sourceMappingURL=encode.d.ts.map

@@ -5,10 +5,11 @@ import htmlTrie from "./generated/encode-html.js";

/**
* Encodes all entities and non-ASCII characters in the input.
* Encodes all characters in the input using HTML entities. This includes
* characters that are valid ASCII characters in HTML documents, such as `#`.
*
* This includes characters that are valid ASCII characters in HTML documents.
* For example `#` will be encoded as `&num;`. To get a more compact output,
* consider using the `encodeNonAsciiHTML` function.
* To get a more compact output, consider using the `encodeNonAsciiHTML`
* function, which will only encode characters that are not valid in HTML
* documents, as well as non-ASCII characters.
*
* If a character has no equivalent entity, a
* numeric hexadecimal reference (eg. `&#xfc;`) will be used.
* If a character has no equivalent entity, a numeric hexadecimal reference
* (eg. `&#xfc;`) will be used.
*/

@@ -20,6 +21,7 @@ export function encodeHTML(data) {

* Encodes all non-ASCII characters, as well as characters not valid in HTML
* documents using HTML entities.
* documents using HTML entities. This function will not encode characters that
* are valid in HTML documents, such as `#`.
*
* If a character has no equivalent entity, a
* numeric hexadecimal reference (eg. `&#xfc;`) will be used.
* If a character has no equivalent entity, a numeric hexadecimal reference
* (eg. `&#xfc;`) will be used.
*/

@@ -26,0 +28,0 @@ export function encodeNonAsciiHTML(data) {

@@ -18,3 +18,3 @@ /** The level of entities to support. */

* The output is UTF-8 encoded. Only characters that need escaping within
* HTML will be escaped.
* XML will be escaped.
*/

@@ -21,0 +21,0 @@ UTF8 = 0,

@@ -24,3 +24,3 @@ import { decodeXML, decodeHTML, decodeHTMLStrict } from "./decode.js";

* The output is UTF-8 encoded. Only characters that need escaping within
* HTML will be escaped.
* XML will be escaped.
*/

@@ -27,0 +27,0 @@ EncodingMode[EncodingMode["UTF8"] = 0] = "UTF8";

@@ -18,3 +18,3 @@ /** The level of entities to support. */

* The output is UTF-8 encoded. Only characters that need escaping within
* HTML will be escaped.
* XML will be escaped.
*/

@@ -21,0 +21,0 @@ UTF8 = 0,

@@ -27,3 +27,3 @@ "use strict";

* The output is UTF-8 encoded. Only characters that need escaping within
* HTML will be escaped.
* XML will be escaped.
*/

@@ -30,0 +30,0 @@ EncodingMode[EncodingMode["UTF8"] = 0] = "UTF8";

{
"name": "entities",
"version": "4.3.0",
"version": "4.3.1",
"description": "Encode & decode XML and HTML entities with ease & speed",

@@ -43,14 +43,14 @@ "author": "Felix Boehm <me@feedic.com>",

"devDependencies": {
"@types/jest": "^27.4.1",
"@types/node": "^17.0.23",
"@typescript-eslint/eslint-plugin": "^5.18.0",
"@typescript-eslint/parser": "^5.18.0",
"eslint": "^8.12.0",
"@types/jest": "^28.1.4",
"@types/node": "^18.0.0",
"@typescript-eslint/eslint-plugin": "^5.30.0",
"@typescript-eslint/parser": "^5.30.0",
"eslint": "^8.18.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-node": "^11.1.0",
"jest": "^27.5.1",
"prettier": "^2.6.2",
"ts-jest": "^27.1.4",
"typedoc": "^0.22.14",
"typescript": "^4.6.3"
"jest": "^28.1.2",
"prettier": "^2.7.1",
"ts-jest": "^28.0.5",
"typedoc": "^0.23.2",
"typescript": "^4.7.4"
},

@@ -82,3 +82,2 @@ "scripts": {

"preset": "ts-jest",
"testEnvironment": "node",
"coverageProvider": "v8",

@@ -85,0 +84,0 @@ "moduleNameMapper": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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