entities 4.5.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/decode.js +3 -0
- package/{lib/decode_codepoint.d.ts → dist/commonjs/decode-codepoint.d.ts} +2 -2
- package/dist/commonjs/decode-codepoint.d.ts.map +1 -0
- package/{lib/decode_codepoint.js → dist/commonjs/decode-codepoint.js} +14 -13
- package/dist/commonjs/decode-codepoint.js.map +1 -0
- package/{lib → dist/commonjs}/decode.d.ts +18 -20
- package/dist/commonjs/decode.d.ts.map +1 -0
- package/{lib → dist/commonjs}/decode.js +122 -147
- package/dist/commonjs/decode.js.map +1 -0
- package/{lib/esm → dist/commonjs}/encode.d.ts +2 -2
- package/dist/commonjs/encode.d.ts.map +1 -0
- package/{lib → dist/commonjs}/encode.js +31 -35
- package/dist/commonjs/encode.js.map +1 -0
- package/{lib/esm → dist/commonjs}/escape.d.ts +2 -2
- package/dist/commonjs/escape.d.ts.map +1 -0
- package/{lib → dist/commonjs}/escape.js +37 -38
- package/dist/commonjs/escape.js.map +1 -0
- package/dist/commonjs/generated/decode-data-html.d.ts +2 -0
- package/dist/commonjs/generated/decode-data-html.d.ts.map +1 -0
- package/dist/commonjs/generated/decode-data-html.js +10 -0
- package/dist/commonjs/generated/decode-data-html.js.map +1 -0
- package/dist/commonjs/generated/decode-data-xml.d.ts +2 -0
- package/dist/commonjs/generated/decode-data-xml.d.ts.map +1 -0
- package/dist/commonjs/generated/decode-data-xml.js +10 -0
- package/dist/commonjs/generated/decode-data-xml.js.map +1 -0
- package/dist/commonjs/generated/encode-html.d.ts +8 -0
- package/dist/commonjs/generated/encode-html.d.ts.map +1 -0
- package/dist/commonjs/generated/encode-html.js +13 -0
- package/dist/commonjs/generated/encode-html.js.map +1 -0
- package/{lib → dist/commonjs}/index.d.ts +6 -6
- package/dist/commonjs/index.d.ts.map +1 -0
- package/{lib → dist/commonjs}/index.js +44 -39
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/{lib/esm/decode_codepoint.d.ts → dist/esm/decode-codepoint.d.ts} +2 -2
- package/dist/esm/decode-codepoint.d.ts.map +1 -0
- package/{lib/esm/decode_codepoint.js → dist/esm/decode-codepoint.js} +10 -9
- package/dist/esm/decode-codepoint.js.map +1 -0
- package/{lib → dist}/esm/decode.d.ts +18 -20
- package/dist/esm/decode.d.ts.map +1 -0
- package/{lib → dist}/esm/decode.js +76 -75
- package/dist/esm/decode.js.map +1 -0
- package/{lib → dist/esm}/encode.d.ts +2 -2
- package/dist/esm/encode.d.ts.map +1 -0
- package/{lib → dist}/esm/encode.js +25 -25
- package/dist/esm/encode.js.map +1 -0
- package/{lib → dist/esm}/escape.d.ts +2 -2
- package/dist/esm/escape.d.ts.map +1 -0
- package/{lib → dist}/esm/escape.js +31 -30
- package/dist/esm/escape.js.map +1 -0
- package/dist/esm/generated/decode-data-html.d.ts +2 -0
- package/dist/esm/generated/decode-data-html.d.ts.map +1 -0
- package/dist/esm/generated/decode-data-html.js +7 -0
- package/dist/esm/generated/decode-data-html.js.map +1 -0
- package/dist/esm/generated/decode-data-xml.d.ts +2 -0
- package/dist/esm/generated/decode-data-xml.d.ts.map +1 -0
- package/dist/esm/generated/decode-data-xml.js +7 -0
- package/dist/esm/generated/decode-data-xml.js.map +1 -0
- package/dist/esm/generated/encode-html.d.ts +8 -0
- package/dist/esm/generated/encode-html.d.ts.map +1 -0
- package/dist/esm/generated/encode-html.js +10 -0
- package/dist/esm/generated/encode-html.js.map +1 -0
- package/{lib → dist}/esm/index.d.ts +6 -6
- package/dist/esm/index.d.ts.map +1 -0
- package/{lib → dist}/esm/index.js +33 -25
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/escape.js +3 -0
- package/package.json +92 -66
- package/readme.md +19 -19
- package/src/decode-codepoint.ts +81 -0
- package/src/decode.spec.ts +320 -0
- package/src/decode.ts +620 -0
- package/src/encode.spec.ts +78 -0
- package/src/encode.ts +77 -0
- package/src/escape.spec.ts +14 -0
- package/src/escape.ts +148 -0
- package/src/generated/.eslintrc.json +10 -0
- package/src/generated/decode-data-html.ts +8 -0
- package/src/generated/decode-data-xml.ts +8 -0
- package/src/generated/encode-html.ts +17 -0
- package/src/index.spec.ts +125 -0
- package/src/index.ts +188 -0
- package/lib/decode.d.ts.map +0 -1
- package/lib/decode.js.map +0 -1
- package/lib/decode_codepoint.d.ts.map +0 -1
- package/lib/decode_codepoint.js.map +0 -1
- package/lib/encode.d.ts.map +0 -1
- package/lib/encode.js.map +0 -1
- package/lib/escape.d.ts.map +0 -1
- package/lib/escape.js.map +0 -1
- package/lib/esm/decode.d.ts.map +0 -1
- package/lib/esm/decode.js.map +0 -1
- package/lib/esm/decode_codepoint.d.ts.map +0 -1
- package/lib/esm/decode_codepoint.js.map +0 -1
- package/lib/esm/encode.d.ts.map +0 -1
- package/lib/esm/encode.js.map +0 -1
- package/lib/esm/escape.d.ts.map +0 -1
- package/lib/esm/escape.js.map +0 -1
- package/lib/esm/generated/decode-data-html.d.ts +0 -3
- package/lib/esm/generated/decode-data-html.d.ts.map +0 -1
- package/lib/esm/generated/decode-data-html.js +0 -7
- package/lib/esm/generated/decode-data-html.js.map +0 -1
- package/lib/esm/generated/decode-data-xml.d.ts +0 -3
- package/lib/esm/generated/decode-data-xml.d.ts.map +0 -1
- package/lib/esm/generated/decode-data-xml.js +0 -7
- package/lib/esm/generated/decode-data-xml.js.map +0 -1
- package/lib/esm/generated/encode-html.d.ts +0 -8
- package/lib/esm/generated/encode-html.d.ts.map +0 -1
- package/lib/esm/generated/encode-html.js +0 -10
- package/lib/esm/generated/encode-html.js.map +0 -1
- package/lib/esm/index.d.ts.map +0 -1
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/package.json +0 -1
- package/lib/generated/decode-data-html.d.ts +0 -3
- package/lib/generated/decode-data-html.d.ts.map +0 -1
- package/lib/generated/decode-data-html.js +0 -9
- package/lib/generated/decode-data-html.js.map +0 -1
- package/lib/generated/decode-data-xml.d.ts +0 -3
- package/lib/generated/decode-data-xml.d.ts.map +0 -1
- package/lib/generated/decode-data-xml.js +0 -9
- package/lib/generated/decode-data-xml.js.map +0 -1
- package/lib/generated/encode-html.d.ts +0 -8
- package/lib/generated/encode-html.d.ts.map +0 -1
- package/lib/generated/encode-html.js +0 -12
- package/lib/generated/encode-html.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
|
@@ -1,41 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
30
|
-
|
|
31
|
-
exports.
|
|
32
|
-
|
|
33
|
-
exports.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
Object.defineProperty(exports, "fromCodePoint", { enumerable: true, get: function () { return decode_codepoint_js_2.fromCodePoint; } });
|
|
3
|
+
exports.fromCodePoint = exports.replaceCodePoint = exports.decodeCodePoint = exports.xmlDecodeTree = exports.htmlDecodeTree = exports.EntityDecoder = exports.DecodingMode = exports.BinTrieFlags = void 0;
|
|
4
|
+
exports.determineBranch = determineBranch;
|
|
5
|
+
exports.decodeHTML = decodeHTML;
|
|
6
|
+
exports.decodeHTMLAttribute = decodeHTMLAttribute;
|
|
7
|
+
exports.decodeHTMLStrict = decodeHTMLStrict;
|
|
8
|
+
exports.decodeXML = decodeXML;
|
|
9
|
+
const decode_data_html_js_1 = require("./generated/decode-data-html.js");
|
|
10
|
+
const decode_data_xml_js_1 = require("./generated/decode-data-xml.js");
|
|
11
|
+
const decode_codepoint_js_1 = require("./decode-codepoint.js");
|
|
39
12
|
var CharCodes;
|
|
40
13
|
(function (CharCodes) {
|
|
41
14
|
CharCodes[CharCodes["NUM"] = 35] = "NUM";
|
|
@@ -52,13 +25,13 @@ var CharCodes;
|
|
|
52
25
|
CharCodes[CharCodes["UPPER_Z"] = 90] = "UPPER_Z";
|
|
53
26
|
})(CharCodes || (CharCodes = {}));
|
|
54
27
|
/** Bit that needs to be set to convert an upper case ASCII character to lower case */
|
|
55
|
-
|
|
28
|
+
const TO_LOWER_BIT = 32;
|
|
56
29
|
var BinTrieFlags;
|
|
57
30
|
(function (BinTrieFlags) {
|
|
58
31
|
BinTrieFlags[BinTrieFlags["VALUE_LENGTH"] = 49152] = "VALUE_LENGTH";
|
|
59
32
|
BinTrieFlags[BinTrieFlags["BRANCH_LENGTH"] = 16256] = "BRANCH_LENGTH";
|
|
60
33
|
BinTrieFlags[BinTrieFlags["JUMP_TABLE"] = 127] = "JUMP_TABLE";
|
|
61
|
-
})(BinTrieFlags
|
|
34
|
+
})(BinTrieFlags || (exports.BinTrieFlags = BinTrieFlags = {}));
|
|
62
35
|
function isNumber(code) {
|
|
63
36
|
return code >= CharCodes.ZERO && code <= CharCodes.NINE;
|
|
64
37
|
}
|
|
@@ -96,12 +69,12 @@ var DecodingMode;
|
|
|
96
69
|
DecodingMode[DecodingMode["Strict"] = 1] = "Strict";
|
|
97
70
|
/** Entities in attributes have limitations on ending characters. */
|
|
98
71
|
DecodingMode[DecodingMode["Attribute"] = 2] = "Attribute";
|
|
99
|
-
})(DecodingMode
|
|
72
|
+
})(DecodingMode || (exports.DecodingMode = DecodingMode = {}));
|
|
100
73
|
/**
|
|
101
74
|
* Token decoder with support of writing partial entities.
|
|
102
75
|
*/
|
|
103
|
-
|
|
104
|
-
|
|
76
|
+
class EntityDecoder {
|
|
77
|
+
constructor(
|
|
105
78
|
/** The tree used to decode entities. */
|
|
106
79
|
decodeTree,
|
|
107
80
|
/**
|
|
@@ -138,14 +111,14 @@ var EntityDecoder = /** @class */ (function () {
|
|
|
138
111
|
this.decodeMode = DecodingMode.Strict;
|
|
139
112
|
}
|
|
140
113
|
/** Resets the instance to make it reusable. */
|
|
141
|
-
|
|
114
|
+
startEntity(decodeMode) {
|
|
142
115
|
this.decodeMode = decodeMode;
|
|
143
116
|
this.state = EntityDecoderState.EntityStart;
|
|
144
117
|
this.result = 0;
|
|
145
118
|
this.treeIndex = 0;
|
|
146
119
|
this.excess = 1;
|
|
147
120
|
this.consumed = 1;
|
|
148
|
-
}
|
|
121
|
+
}
|
|
149
122
|
/**
|
|
150
123
|
* Write an entity to the decoder. This can be called multiple times with partial entities.
|
|
151
124
|
* If the entity is incomplete, the decoder will return -1.
|
|
@@ -153,113 +126,113 @@ var EntityDecoder = /** @class */ (function () {
|
|
|
153
126
|
* Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the
|
|
154
127
|
* entity is incomplete, and resume when the next string is written.
|
|
155
128
|
*
|
|
156
|
-
* @param
|
|
129
|
+
* @param input The string containing the entity (or a continuation of the entity).
|
|
157
130
|
* @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
|
|
158
131
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
159
132
|
*/
|
|
160
|
-
|
|
133
|
+
write(input, offset) {
|
|
161
134
|
switch (this.state) {
|
|
162
135
|
case EntityDecoderState.EntityStart: {
|
|
163
|
-
if (
|
|
136
|
+
if (input.charCodeAt(offset) === CharCodes.NUM) {
|
|
164
137
|
this.state = EntityDecoderState.NumericStart;
|
|
165
138
|
this.consumed += 1;
|
|
166
|
-
return this.stateNumericStart(
|
|
139
|
+
return this.stateNumericStart(input, offset + 1);
|
|
167
140
|
}
|
|
168
141
|
this.state = EntityDecoderState.NamedEntity;
|
|
169
|
-
return this.stateNamedEntity(
|
|
142
|
+
return this.stateNamedEntity(input, offset);
|
|
170
143
|
}
|
|
171
144
|
case EntityDecoderState.NumericStart: {
|
|
172
|
-
return this.stateNumericStart(
|
|
145
|
+
return this.stateNumericStart(input, offset);
|
|
173
146
|
}
|
|
174
147
|
case EntityDecoderState.NumericDecimal: {
|
|
175
|
-
return this.stateNumericDecimal(
|
|
148
|
+
return this.stateNumericDecimal(input, offset);
|
|
176
149
|
}
|
|
177
150
|
case EntityDecoderState.NumericHex: {
|
|
178
|
-
return this.stateNumericHex(
|
|
151
|
+
return this.stateNumericHex(input, offset);
|
|
179
152
|
}
|
|
180
153
|
case EntityDecoderState.NamedEntity: {
|
|
181
|
-
return this.stateNamedEntity(
|
|
154
|
+
return this.stateNamedEntity(input, offset);
|
|
182
155
|
}
|
|
183
156
|
}
|
|
184
|
-
}
|
|
157
|
+
}
|
|
185
158
|
/**
|
|
186
159
|
* Switches between the numeric decimal and hexadecimal states.
|
|
187
160
|
*
|
|
188
161
|
* Equivalent to the `Numeric character reference state` in the HTML spec.
|
|
189
162
|
*
|
|
190
|
-
* @param
|
|
163
|
+
* @param input The string containing the entity (or a continuation of the entity).
|
|
191
164
|
* @param offset The current offset.
|
|
192
165
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
193
166
|
*/
|
|
194
|
-
|
|
195
|
-
if (offset >=
|
|
167
|
+
stateNumericStart(input, offset) {
|
|
168
|
+
if (offset >= input.length) {
|
|
196
169
|
return -1;
|
|
197
170
|
}
|
|
198
|
-
if ((
|
|
171
|
+
if ((input.charCodeAt(offset) | TO_LOWER_BIT) === CharCodes.LOWER_X) {
|
|
199
172
|
this.state = EntityDecoderState.NumericHex;
|
|
200
173
|
this.consumed += 1;
|
|
201
|
-
return this.stateNumericHex(
|
|
174
|
+
return this.stateNumericHex(input, offset + 1);
|
|
202
175
|
}
|
|
203
176
|
this.state = EntityDecoderState.NumericDecimal;
|
|
204
|
-
return this.stateNumericDecimal(
|
|
205
|
-
}
|
|
206
|
-
|
|
177
|
+
return this.stateNumericDecimal(input, offset);
|
|
178
|
+
}
|
|
179
|
+
addToNumericResult(input, start, end, base) {
|
|
207
180
|
if (start !== end) {
|
|
208
|
-
|
|
181
|
+
const digitCount = end - start;
|
|
209
182
|
this.result =
|
|
210
183
|
this.result * Math.pow(base, digitCount) +
|
|
211
|
-
parseInt(
|
|
184
|
+
Number.parseInt(input.substr(start, digitCount), base);
|
|
212
185
|
this.consumed += digitCount;
|
|
213
186
|
}
|
|
214
|
-
}
|
|
187
|
+
}
|
|
215
188
|
/**
|
|
216
189
|
* Parses a hexadecimal numeric entity.
|
|
217
190
|
*
|
|
218
191
|
* Equivalent to the `Hexademical character reference state` in the HTML spec.
|
|
219
192
|
*
|
|
220
|
-
* @param
|
|
193
|
+
* @param input The string containing the entity (or a continuation of the entity).
|
|
221
194
|
* @param offset The current offset.
|
|
222
195
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
223
196
|
*/
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
while (offset <
|
|
227
|
-
|
|
197
|
+
stateNumericHex(input, offset) {
|
|
198
|
+
const startIndex = offset;
|
|
199
|
+
while (offset < input.length) {
|
|
200
|
+
const char = input.charCodeAt(offset);
|
|
228
201
|
if (isNumber(char) || isHexadecimalCharacter(char)) {
|
|
229
202
|
offset += 1;
|
|
230
203
|
}
|
|
231
204
|
else {
|
|
232
|
-
this.addToNumericResult(
|
|
205
|
+
this.addToNumericResult(input, startIndex, offset, 16);
|
|
233
206
|
return this.emitNumericEntity(char, 3);
|
|
234
207
|
}
|
|
235
208
|
}
|
|
236
|
-
this.addToNumericResult(
|
|
209
|
+
this.addToNumericResult(input, startIndex, offset, 16);
|
|
237
210
|
return -1;
|
|
238
|
-
}
|
|
211
|
+
}
|
|
239
212
|
/**
|
|
240
213
|
* Parses a decimal numeric entity.
|
|
241
214
|
*
|
|
242
215
|
* Equivalent to the `Decimal character reference state` in the HTML spec.
|
|
243
216
|
*
|
|
244
|
-
* @param
|
|
217
|
+
* @param input The string containing the entity (or a continuation of the entity).
|
|
245
218
|
* @param offset The current offset.
|
|
246
219
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
247
220
|
*/
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
while (offset <
|
|
251
|
-
|
|
221
|
+
stateNumericDecimal(input, offset) {
|
|
222
|
+
const startIndex = offset;
|
|
223
|
+
while (offset < input.length) {
|
|
224
|
+
const char = input.charCodeAt(offset);
|
|
252
225
|
if (isNumber(char)) {
|
|
253
226
|
offset += 1;
|
|
254
227
|
}
|
|
255
228
|
else {
|
|
256
|
-
this.addToNumericResult(
|
|
229
|
+
this.addToNumericResult(input, startIndex, offset, 10);
|
|
257
230
|
return this.emitNumericEntity(char, 2);
|
|
258
231
|
}
|
|
259
232
|
}
|
|
260
|
-
this.addToNumericResult(
|
|
233
|
+
this.addToNumericResult(input, startIndex, offset, 10);
|
|
261
234
|
return -1;
|
|
262
|
-
}
|
|
235
|
+
}
|
|
263
236
|
/**
|
|
264
237
|
* Validate and emit a numeric entity.
|
|
265
238
|
*
|
|
@@ -273,7 +246,7 @@ var EntityDecoder = /** @class */ (function () {
|
|
|
273
246
|
* was consumed.
|
|
274
247
|
* @returns The number of characters that were consumed.
|
|
275
248
|
*/
|
|
276
|
-
|
|
249
|
+
emitNumericEntity(lastCp, expectedLength) {
|
|
277
250
|
var _a;
|
|
278
251
|
// Ensure we consumed at least one digit.
|
|
279
252
|
if (this.consumed <= expectedLength) {
|
|
@@ -295,23 +268,23 @@ var EntityDecoder = /** @class */ (function () {
|
|
|
295
268
|
this.errors.validateNumericCharacterReference(this.result);
|
|
296
269
|
}
|
|
297
270
|
return this.consumed;
|
|
298
|
-
}
|
|
271
|
+
}
|
|
299
272
|
/**
|
|
300
273
|
* Parses a named entity.
|
|
301
274
|
*
|
|
302
275
|
* Equivalent to the `Named character reference state` in the HTML spec.
|
|
303
276
|
*
|
|
304
|
-
* @param
|
|
277
|
+
* @param input The string containing the entity (or a continuation of the entity).
|
|
305
278
|
* @param offset The current offset.
|
|
306
279
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
307
280
|
*/
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
281
|
+
stateNamedEntity(input, offset) {
|
|
282
|
+
const { decodeTree } = this;
|
|
283
|
+
let current = decodeTree[this.treeIndex];
|
|
311
284
|
// The mask is the number of bytes of the value, including the current byte.
|
|
312
|
-
|
|
313
|
-
for (; offset <
|
|
314
|
-
|
|
285
|
+
let valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
|
|
286
|
+
for (; offset < input.length; offset++, this.excess++) {
|
|
287
|
+
const char = input.charCodeAt(offset);
|
|
315
288
|
this.treeIndex = determineBranch(decodeTree, current, this.treeIndex + Math.max(1, valueLength), char);
|
|
316
289
|
if (this.treeIndex < 0) {
|
|
317
290
|
return this.result === 0 ||
|
|
@@ -341,20 +314,20 @@ var EntityDecoder = /** @class */ (function () {
|
|
|
341
314
|
}
|
|
342
315
|
}
|
|
343
316
|
return -1;
|
|
344
|
-
}
|
|
317
|
+
}
|
|
345
318
|
/**
|
|
346
319
|
* Emit a named entity that was not terminated with a semicolon.
|
|
347
320
|
*
|
|
348
321
|
* @returns The number of characters consumed.
|
|
349
322
|
*/
|
|
350
|
-
|
|
323
|
+
emitNotTerminatedNamedEntity() {
|
|
351
324
|
var _a;
|
|
352
|
-
|
|
353
|
-
|
|
325
|
+
const { result, decodeTree } = this;
|
|
326
|
+
const valueLength = (decodeTree[result] & BinTrieFlags.VALUE_LENGTH) >> 14;
|
|
354
327
|
this.emitNamedEntityData(result, valueLength, this.consumed);
|
|
355
328
|
(_a = this.errors) === null || _a === void 0 ? void 0 : _a.missingSemicolonAfterCharacterReference();
|
|
356
329
|
return this.consumed;
|
|
357
|
-
}
|
|
330
|
+
}
|
|
358
331
|
/**
|
|
359
332
|
* Emit a named entity.
|
|
360
333
|
*
|
|
@@ -364,8 +337,8 @@ var EntityDecoder = /** @class */ (function () {
|
|
|
364
337
|
*
|
|
365
338
|
* @returns The number of characters consumed.
|
|
366
339
|
*/
|
|
367
|
-
|
|
368
|
-
|
|
340
|
+
emitNamedEntityData(result, valueLength, consumed) {
|
|
341
|
+
const { decodeTree } = this;
|
|
369
342
|
this.emitCodePoint(valueLength === 1
|
|
370
343
|
? decodeTree[result] & ~BinTrieFlags.VALUE_LENGTH
|
|
371
344
|
: decodeTree[result + 1], consumed);
|
|
@@ -374,7 +347,7 @@ var EntityDecoder = /** @class */ (function () {
|
|
|
374
347
|
this.emitCodePoint(decodeTree[result + 2], consumed);
|
|
375
348
|
}
|
|
376
349
|
return consumed;
|
|
377
|
-
}
|
|
350
|
+
}
|
|
378
351
|
/**
|
|
379
352
|
* Signal to the parser that the end of the input was reached.
|
|
380
353
|
*
|
|
@@ -382,7 +355,7 @@ var EntityDecoder = /** @class */ (function () {
|
|
|
382
355
|
*
|
|
383
356
|
* @returns The number of characters consumed.
|
|
384
357
|
*/
|
|
385
|
-
|
|
358
|
+
end() {
|
|
386
359
|
var _a;
|
|
387
360
|
switch (this.state) {
|
|
388
361
|
case EntityDecoderState.NamedEntity: {
|
|
@@ -409,9 +382,8 @@ var EntityDecoder = /** @class */ (function () {
|
|
|
409
382
|
return 0;
|
|
410
383
|
}
|
|
411
384
|
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
}());
|
|
385
|
+
}
|
|
386
|
+
}
|
|
415
387
|
exports.EntityDecoder = EntityDecoder;
|
|
416
388
|
/**
|
|
417
389
|
* Creates a function that decodes entities in a string.
|
|
@@ -420,28 +392,28 @@ exports.EntityDecoder = EntityDecoder;
|
|
|
420
392
|
* @returns A function that decodes entities in a string.
|
|
421
393
|
*/
|
|
422
394
|
function getDecoder(decodeTree) {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
return function decodeWithTrie(
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
while ((offset =
|
|
429
|
-
|
|
395
|
+
let returnValue = "";
|
|
396
|
+
const decoder = new EntityDecoder(decodeTree, (data) => (returnValue += (0, decode_codepoint_js_1.fromCodePoint)(data)));
|
|
397
|
+
return function decodeWithTrie(input, decodeMode) {
|
|
398
|
+
let lastIndex = 0;
|
|
399
|
+
let offset = 0;
|
|
400
|
+
while ((offset = input.indexOf("&", offset)) >= 0) {
|
|
401
|
+
returnValue += input.slice(lastIndex, offset);
|
|
430
402
|
decoder.startEntity(decodeMode);
|
|
431
|
-
|
|
403
|
+
const length = decoder.write(input,
|
|
432
404
|
// Skip the "&"
|
|
433
405
|
offset + 1);
|
|
434
|
-
if (
|
|
406
|
+
if (length < 0) {
|
|
435
407
|
lastIndex = offset + decoder.end();
|
|
436
408
|
break;
|
|
437
409
|
}
|
|
438
|
-
lastIndex = offset +
|
|
439
|
-
// If `
|
|
440
|
-
offset =
|
|
410
|
+
lastIndex = offset + length;
|
|
411
|
+
// If `length` is 0, skip the current `&` and continue.
|
|
412
|
+
offset = length === 0 ? lastIndex + 1 : lastIndex;
|
|
441
413
|
}
|
|
442
|
-
|
|
414
|
+
const result = returnValue + input.slice(lastIndex);
|
|
443
415
|
// Make sure we don't keep a reference to the final string.
|
|
444
|
-
|
|
416
|
+
returnValue = "";
|
|
445
417
|
return result;
|
|
446
418
|
};
|
|
447
419
|
}
|
|
@@ -455,31 +427,31 @@ function getDecoder(decodeTree) {
|
|
|
455
427
|
* @param char The current character.
|
|
456
428
|
* @returns The index of the next node, or -1 if no branch is taken.
|
|
457
429
|
*/
|
|
458
|
-
function determineBranch(decodeTree, current,
|
|
459
|
-
|
|
460
|
-
|
|
430
|
+
function determineBranch(decodeTree, current, nodeIndex, char) {
|
|
431
|
+
const branchCount = (current & BinTrieFlags.BRANCH_LENGTH) >> 7;
|
|
432
|
+
const jumpOffset = current & BinTrieFlags.JUMP_TABLE;
|
|
461
433
|
// Case 1: Single branch encoded in jump offset
|
|
462
434
|
if (branchCount === 0) {
|
|
463
|
-
return jumpOffset !== 0 && char === jumpOffset ?
|
|
435
|
+
return jumpOffset !== 0 && char === jumpOffset ? nodeIndex : -1;
|
|
464
436
|
}
|
|
465
437
|
// Case 2: Multiple branches encoded in jump table
|
|
466
438
|
if (jumpOffset) {
|
|
467
|
-
|
|
439
|
+
const value = char - jumpOffset;
|
|
468
440
|
return value < 0 || value >= branchCount
|
|
469
441
|
? -1
|
|
470
|
-
: decodeTree[
|
|
442
|
+
: decodeTree[nodeIndex + value] - 1;
|
|
471
443
|
}
|
|
472
444
|
// Case 3: Multiple branches encoded in dictionary
|
|
473
445
|
// Binary search for the character.
|
|
474
|
-
|
|
475
|
-
|
|
446
|
+
let lo = nodeIndex;
|
|
447
|
+
let hi = lo + branchCount - 1;
|
|
476
448
|
while (lo <= hi) {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
if (
|
|
449
|
+
const mid = (lo + hi) >>> 1;
|
|
450
|
+
const midValue = decodeTree[mid];
|
|
451
|
+
if (midValue < char) {
|
|
480
452
|
lo = mid + 1;
|
|
481
453
|
}
|
|
482
|
-
else if (
|
|
454
|
+
else if (midValue > char) {
|
|
483
455
|
hi = mid - 1;
|
|
484
456
|
}
|
|
485
457
|
else {
|
|
@@ -488,49 +460,52 @@ function determineBranch(decodeTree, current, nodeIdx, char) {
|
|
|
488
460
|
}
|
|
489
461
|
return -1;
|
|
490
462
|
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
var xmlDecoder = getDecoder(decode_data_xml_js_1.default);
|
|
463
|
+
const htmlDecoder = /* #__PURE__ */ getDecoder(decode_data_html_js_1.htmlDecodeTree);
|
|
464
|
+
const xmlDecoder = /* #__PURE__ */ getDecoder(decode_data_xml_js_1.xmlDecodeTree);
|
|
494
465
|
/**
|
|
495
466
|
* Decodes an HTML string.
|
|
496
467
|
*
|
|
497
|
-
* @param
|
|
468
|
+
* @param htmlString The string to decode.
|
|
498
469
|
* @param mode The decoding mode.
|
|
499
470
|
* @returns The decoded string.
|
|
500
471
|
*/
|
|
501
|
-
function decodeHTML(
|
|
502
|
-
|
|
503
|
-
return htmlDecoder(str, mode);
|
|
472
|
+
function decodeHTML(htmlString, mode = DecodingMode.Legacy) {
|
|
473
|
+
return htmlDecoder(htmlString, mode);
|
|
504
474
|
}
|
|
505
|
-
exports.decodeHTML = decodeHTML;
|
|
506
475
|
/**
|
|
507
476
|
* Decodes an HTML string in an attribute.
|
|
508
477
|
*
|
|
509
|
-
* @param
|
|
478
|
+
* @param htmlAttribute The string to decode.
|
|
510
479
|
* @returns The decoded string.
|
|
511
480
|
*/
|
|
512
|
-
function decodeHTMLAttribute(
|
|
513
|
-
return htmlDecoder(
|
|
481
|
+
function decodeHTMLAttribute(htmlAttribute) {
|
|
482
|
+
return htmlDecoder(htmlAttribute, DecodingMode.Attribute);
|
|
514
483
|
}
|
|
515
|
-
exports.decodeHTMLAttribute = decodeHTMLAttribute;
|
|
516
484
|
/**
|
|
517
485
|
* Decodes an HTML string, requiring all entities to be terminated by a semicolon.
|
|
518
486
|
*
|
|
519
|
-
* @param
|
|
487
|
+
* @param htmlString The string to decode.
|
|
520
488
|
* @returns The decoded string.
|
|
521
489
|
*/
|
|
522
|
-
function decodeHTMLStrict(
|
|
523
|
-
return htmlDecoder(
|
|
490
|
+
function decodeHTMLStrict(htmlString) {
|
|
491
|
+
return htmlDecoder(htmlString, DecodingMode.Strict);
|
|
524
492
|
}
|
|
525
|
-
exports.decodeHTMLStrict = decodeHTMLStrict;
|
|
526
493
|
/**
|
|
527
494
|
* Decodes an XML string, requiring all entities to be terminated by a semicolon.
|
|
528
495
|
*
|
|
529
|
-
* @param
|
|
496
|
+
* @param xmlString The string to decode.
|
|
530
497
|
* @returns The decoded string.
|
|
531
498
|
*/
|
|
532
|
-
function decodeXML(
|
|
533
|
-
return xmlDecoder(
|
|
499
|
+
function decodeXML(xmlString) {
|
|
500
|
+
return xmlDecoder(xmlString, DecodingMode.Strict);
|
|
534
501
|
}
|
|
535
|
-
|
|
502
|
+
// Re-export for use by eg. htmlparser2
|
|
503
|
+
var decode_data_html_js_2 = require("./generated/decode-data-html.js");
|
|
504
|
+
Object.defineProperty(exports, "htmlDecodeTree", { enumerable: true, get: function () { return decode_data_html_js_2.htmlDecodeTree; } });
|
|
505
|
+
var decode_data_xml_js_2 = require("./generated/decode-data-xml.js");
|
|
506
|
+
Object.defineProperty(exports, "xmlDecodeTree", { enumerable: true, get: function () { return decode_data_xml_js_2.xmlDecodeTree; } });
|
|
507
|
+
var decode_codepoint_js_2 = require("./decode-codepoint.js");
|
|
508
|
+
Object.defineProperty(exports, "decodeCodePoint", { enumerable: true, get: function () { return decode_codepoint_js_2.decodeCodePoint; } });
|
|
509
|
+
Object.defineProperty(exports, "replaceCodePoint", { enumerable: true, get: function () { return decode_codepoint_js_2.replaceCodePoint; } });
|
|
510
|
+
Object.defineProperty(exports, "fromCodePoint", { enumerable: true, get: function () { return decode_codepoint_js_2.fromCodePoint; } });
|
|
536
511
|
//# sourceMappingURL=decode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode.js","sourceRoot":"","sources":["../../src/decode.ts"],"names":[],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CAAC,SAAS,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;AACtD,CAAC;AAED,uCAAuC;AACvC,uEAAiE;AAAxD,qHAAA,cAAc,OAAA;AACvB,qEAA+D;AAAtD,mHAAA,aAAa,OAAA;AAEtB,6DAI+B;AAH3B,sHAAA,eAAe,OAAA;AACf,uHAAA,gBAAgB,OAAA;AAChB,oHAAA,aAAa,OAAA"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* If a character has no equivalent entity, a numeric hexadecimal reference
|
|
10
10
|
* (eg. `ü`) will be used.
|
|
11
11
|
*/
|
|
12
|
-
export declare function encodeHTML(
|
|
12
|
+
export declare function encodeHTML(input: string): string;
|
|
13
13
|
/**
|
|
14
14
|
* Encodes all non-ASCII characters, as well as characters not valid in HTML
|
|
15
15
|
* documents using HTML entities. This function will not encode characters that
|
|
@@ -18,5 +18,5 @@ export declare function encodeHTML(data: string): string;
|
|
|
18
18
|
* If a character has no equivalent entity, a numeric hexadecimal reference
|
|
19
19
|
* (eg. `ü`) will be used.
|
|
20
20
|
*/
|
|
21
|
-
export declare function encodeNonAsciiHTML(
|
|
21
|
+
export declare function encodeNonAsciiHTML(input: string): string;
|
|
22
22
|
//# sourceMappingURL=encode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../src/encode.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AACD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAExD"}
|