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