Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@joplin/fork-htmlparser2

Package Overview
Dependencies
Maintainers
3
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@joplin/fork-htmlparser2 - npm Package Compare versions

Comparing version 4.1.52 to 4.1.53

84

lib/Tokenizer.d.ts
/** All the states the tokenizer can be in. */
declare const enum State {
Text = 1,
BeforeTagName = 2,
BeforeTagName = 2,//after <
InTagName = 3,

@@ -14,46 +14,47 @@ InSelfClosingTag = 4,

BeforeAttributeValue = 11,
InAttributeValueDq = 12,
InAttributeValueSq = 13,
InAttributeValueDq = 12,// "
InAttributeValueSq = 13,// '
InAttributeValueNq = 14,
BeforeDeclaration = 15,
BeforeDeclaration = 15,// !
InDeclaration = 16,
InProcessingInstruction = 17,
InProcessingInstruction = 17,// ?
BeforeComment = 18,
InComment = 19,
AfterComment1 = 20,
AfterComment2 = 21,
BeforeCdata1 = 22,
BeforeCdata2 = 23,
BeforeCdata3 = 24,
BeforeCdata4 = 25,
BeforeCdata5 = 26,
BeforeCdata6 = 27,
InCdata = 28,
AfterCdata1 = 29,
AfterCdata2 = 30,
BeforeSpecial = 31,
BeforeSpecialEnd = 32,
BeforeScript1 = 33,
BeforeScript2 = 34,
BeforeScript3 = 35,
BeforeScript4 = 36,
BeforeScript5 = 37,
AfterScript1 = 38,
AfterScript2 = 39,
AfterScript3 = 40,
AfterScript4 = 41,
AfterScript5 = 42,
BeforeStyle1 = 43,
BeforeStyle2 = 44,
BeforeStyle3 = 45,
BeforeStyle4 = 46,
AfterStyle1 = 47,
AfterStyle2 = 48,
AfterStyle3 = 49,
AfterStyle4 = 50,
BeforeEntity = 51,
BeforeNumericEntity = 52,
InNamedEntity = 53,
InNumericEntity = 54,
InHexEntity = 55
InSpecialComment = 20,
AfterComment1 = 21,
AfterComment2 = 22,
BeforeCdata1 = 23,// [
BeforeCdata2 = 24,// C
BeforeCdata3 = 25,// D
BeforeCdata4 = 26,// A
BeforeCdata5 = 27,// T
BeforeCdata6 = 28,// A
InCdata = 29,// [
AfterCdata1 = 30,// ]
AfterCdata2 = 31,// ]
BeforeSpecial = 32,//S
BeforeSpecialEnd = 33,//S
BeforeScript1 = 34,//C
BeforeScript2 = 35,//R
BeforeScript3 = 36,//I
BeforeScript4 = 37,//P
BeforeScript5 = 38,//T
AfterScript1 = 39,//C
AfterScript2 = 40,//R
AfterScript3 = 41,//I
AfterScript4 = 42,//P
AfterScript5 = 43,//T
BeforeStyle1 = 44,//T
BeforeStyle2 = 45,//Y
BeforeStyle3 = 46,//L
BeforeStyle4 = 47,//E
AfterStyle1 = 48,//T
AfterStyle2 = 49,//Y
AfterStyle3 = 50,//L
AfterStyle4 = 51,//E
BeforeEntity = 52,//&
BeforeNumericEntity = 53,//#
InNamedEntity = 54,
InNumericEntity = 55,
InHexEntity = 56
}

@@ -130,2 +131,3 @@ declare const enum Special {

_stateInComment(c: string): void;
_stateInSpecialComment(c: string): void;
_stateAfterComment1(c: string): void;

@@ -132,0 +134,0 @@ _stateAfterComment2(c: string): void;

@@ -13,2 +13,5 @@ "use strict";

}
function isASCIIAlpha(c) {
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
}
function ifElseState(upper, SUCCESS, FAILURE) {

@@ -51,23 +54,23 @@ var lower = upper.toLowerCase();

}
var stateBeforeCdata1 = ifElseState("C", 23 /* State.BeforeCdata2 */, 16 /* State.InDeclaration */);
var stateBeforeCdata2 = ifElseState("D", 24 /* State.BeforeCdata3 */, 16 /* State.InDeclaration */);
var stateBeforeCdata3 = ifElseState("A", 25 /* State.BeforeCdata4 */, 16 /* State.InDeclaration */);
var stateBeforeCdata4 = ifElseState("T", 26 /* State.BeforeCdata5 */, 16 /* State.InDeclaration */);
var stateBeforeCdata5 = ifElseState("A", 27 /* State.BeforeCdata6 */, 16 /* State.InDeclaration */);
var stateBeforeScript1 = consumeSpecialNameChar("R", 34 /* State.BeforeScript2 */);
var stateBeforeScript2 = consumeSpecialNameChar("I", 35 /* State.BeforeScript3 */);
var stateBeforeScript3 = consumeSpecialNameChar("P", 36 /* State.BeforeScript4 */);
var stateBeforeScript4 = consumeSpecialNameChar("T", 37 /* State.BeforeScript5 */);
var stateAfterScript1 = ifElseState("R", 39 /* State.AfterScript2 */, 1 /* State.Text */);
var stateAfterScript2 = ifElseState("I", 40 /* State.AfterScript3 */, 1 /* State.Text */);
var stateAfterScript3 = ifElseState("P", 41 /* State.AfterScript4 */, 1 /* State.Text */);
var stateAfterScript4 = ifElseState("T", 42 /* State.AfterScript5 */, 1 /* State.Text */);
var stateBeforeStyle1 = consumeSpecialNameChar("Y", 44 /* State.BeforeStyle2 */);
var stateBeforeStyle2 = consumeSpecialNameChar("L", 45 /* State.BeforeStyle3 */);
var stateBeforeStyle3 = consumeSpecialNameChar("E", 46 /* State.BeforeStyle4 */);
var stateAfterStyle1 = ifElseState("Y", 48 /* State.AfterStyle2 */, 1 /* State.Text */);
var stateAfterStyle2 = ifElseState("L", 49 /* State.AfterStyle3 */, 1 /* State.Text */);
var stateAfterStyle3 = ifElseState("E", 50 /* State.AfterStyle4 */, 1 /* State.Text */);
var stateBeforeEntity = ifElseState("#", 52 /* State.BeforeNumericEntity */, 53 /* State.InNamedEntity */);
var stateBeforeNumericEntity = ifElseState("X", 55 /* State.InHexEntity */, 54 /* State.InNumericEntity */);
var stateBeforeCdata1 = ifElseState("C", 24 /* State.BeforeCdata2 */, 16 /* State.InDeclaration */);
var stateBeforeCdata2 = ifElseState("D", 25 /* State.BeforeCdata3 */, 16 /* State.InDeclaration */);
var stateBeforeCdata3 = ifElseState("A", 26 /* State.BeforeCdata4 */, 16 /* State.InDeclaration */);
var stateBeforeCdata4 = ifElseState("T", 27 /* State.BeforeCdata5 */, 16 /* State.InDeclaration */);
var stateBeforeCdata5 = ifElseState("A", 28 /* State.BeforeCdata6 */, 16 /* State.InDeclaration */);
var stateBeforeScript1 = consumeSpecialNameChar("R", 35 /* State.BeforeScript2 */);
var stateBeforeScript2 = consumeSpecialNameChar("I", 36 /* State.BeforeScript3 */);
var stateBeforeScript3 = consumeSpecialNameChar("P", 37 /* State.BeforeScript4 */);
var stateBeforeScript4 = consumeSpecialNameChar("T", 38 /* State.BeforeScript5 */);
var stateAfterScript1 = ifElseState("R", 40 /* State.AfterScript2 */, 1 /* State.Text */);
var stateAfterScript2 = ifElseState("I", 41 /* State.AfterScript3 */, 1 /* State.Text */);
var stateAfterScript3 = ifElseState("P", 42 /* State.AfterScript4 */, 1 /* State.Text */);
var stateAfterScript4 = ifElseState("T", 43 /* State.AfterScript5 */, 1 /* State.Text */);
var stateBeforeStyle1 = consumeSpecialNameChar("Y", 45 /* State.BeforeStyle2 */);
var stateBeforeStyle2 = consumeSpecialNameChar("L", 46 /* State.BeforeStyle3 */);
var stateBeforeStyle3 = consumeSpecialNameChar("E", 47 /* State.BeforeStyle4 */);
var stateAfterStyle1 = ifElseState("Y", 49 /* State.AfterStyle2 */, 1 /* State.Text */);
var stateAfterStyle2 = ifElseState("L", 50 /* State.AfterStyle3 */, 1 /* State.Text */);
var stateAfterStyle3 = ifElseState("E", 51 /* State.AfterStyle4 */, 1 /* State.Text */);
var stateBeforeEntity = ifElseState("#", 53 /* State.BeforeNumericEntity */, 54 /* State.InNamedEntity */);
var stateBeforeNumericEntity = ifElseState("X", 56 /* State.InHexEntity */, 55 /* State.InNumericEntity */);
var Tokenizer = /** @class */ (function () {

@@ -126,3 +129,3 @@ function Tokenizer(options, cbs) {

this._baseState = 1 /* State.Text */;
this._state = 51 /* State.BeforeEntity */;
this._state = 52 /* State.BeforeEntity */;
this._sectionStart = this._index;

@@ -152,6 +155,9 @@ }

}
else if (!isASCIIAlpha(c)) {
this._state = 1 /* State.Text */;
}
else {
this._state =
!this._xmlMode && (c === "s" || c === "S")
? 31 /* State.BeforeSpecial */
? 32 /* State.BeforeSpecial */
: 3 /* State.InTagName */;

@@ -177,3 +183,3 @@ this._sectionStart = this._index;

if (c === "s" || c === "S") {
this._state = 32 /* State.BeforeSpecialEnd */;
this._state = 33 /* State.BeforeSpecialEnd */;
}

@@ -185,2 +191,6 @@ else {

}
else if (!isASCIIAlpha(c)) {
this._state = 20 /* State.InSpecialComment */;
this._sectionStart = this._index;
}
else {

@@ -277,3 +287,3 @@ this._state = 6 /* State.InClosingTagName */;

this._baseState = this._state;
this._state = 51 /* State.BeforeEntity */;
this._state = 52 /* State.BeforeEntity */;
this._sectionStart = this._index;

@@ -291,3 +301,3 @@ }

this._baseState = this._state;
this._state = 51 /* State.BeforeEntity */;
this._state = 52 /* State.BeforeEntity */;
this._sectionStart = this._index;

@@ -306,3 +316,3 @@ }

this._baseState = this._state;
this._state = 51 /* State.BeforeEntity */;
this._state = 52 /* State.BeforeEntity */;
this._sectionStart = this._index;

@@ -314,3 +324,3 @@ }

c === "["
? 22 /* State.BeforeCdata1 */
? 23 /* State.BeforeCdata1 */
: c === "-"

@@ -345,7 +355,14 @@ ? 18 /* State.BeforeComment */

if (c === "-")
this._state = 20 /* State.AfterComment1 */;
this._state = 21 /* State.AfterComment1 */;
};
Tokenizer.prototype._stateInSpecialComment = function (c) {
if (c === ">") {
this._cbs.oncomment(this._buffer.substring(this._sectionStart, this._index));
this._state = 1 /* State.Text */;
this._sectionStart = this._index + 1;
}
};
Tokenizer.prototype._stateAfterComment1 = function (c) {
if (c === "-") {
this._state = 21 /* State.AfterComment2 */;
this._state = 22 /* State.AfterComment2 */;
}

@@ -370,3 +387,3 @@ else {

if (c === "[") {
this._state = 28 /* State.InCdata */;
this._state = 29 /* State.InCdata */;
this._sectionStart = this._index + 1;

@@ -381,9 +398,9 @@ }

if (c === "]")
this._state = 29 /* State.AfterCdata1 */;
this._state = 30 /* State.AfterCdata1 */;
};
Tokenizer.prototype._stateAfterCdata1 = function (c) {
if (c === "]")
this._state = 30 /* State.AfterCdata2 */;
this._state = 31 /* State.AfterCdata2 */;
else
this._state = 28 /* State.InCdata */;
this._state = 29 /* State.InCdata */;
};

@@ -398,3 +415,3 @@ Tokenizer.prototype._stateAfterCdata2 = function (c) {

else if (c !== "]") {
this._state = 28 /* State.InCdata */;
this._state = 29 /* State.InCdata */;
}

@@ -405,6 +422,6 @@ //else: stay in AFTER_CDATA_2 (`]]]>`)

if (c === "c" || c === "C") {
this._state = 33 /* State.BeforeScript1 */;
this._state = 34 /* State.BeforeScript1 */;
}
else if (c === "t" || c === "T") {
this._state = 43 /* State.BeforeStyle1 */;
this._state = 44 /* State.BeforeStyle1 */;
}

@@ -418,7 +435,7 @@ else {

if (this._special === 2 /* Special.Script */ && (c === "c" || c === "C")) {
this._state = 38 /* State.AfterScript1 */;
this._state = 39 /* State.AfterScript1 */;
}
else if (this._special === 3 /* Special.Style */ &&
(c === "t" || c === "T")) {
this._state = 47 /* State.AfterStyle1 */;
this._state = 48 /* State.AfterStyle1 */;
}

@@ -618,2 +635,5 @@ else

}
else if (this._state === 20 /* State.InSpecialComment */) {
this._stateInSpecialComment(c);
}
else if (this._state === 8 /* State.BeforeAttributeName */) {

@@ -646,6 +666,6 @@ this._stateBeforeAttributeName(c);

}
else if (this._state === 31 /* State.BeforeSpecial */) {
else if (this._state === 32 /* State.BeforeSpecial */) {
this._stateBeforeSpecial(c);
}
else if (this._state === 20 /* State.AfterComment1 */) {
else if (this._state === 21 /* State.AfterComment1 */) {
this._stateAfterComment1(c);

@@ -665,3 +685,3 @@ }

}
else if (this._state === 21 /* State.AfterComment2 */) {
else if (this._state === 22 /* State.AfterComment2 */) {
this._stateAfterComment2(c);

@@ -672,60 +692,60 @@ }

}
else if (this._state === 32 /* State.BeforeSpecialEnd */) {
else if (this._state === 33 /* State.BeforeSpecialEnd */) {
this._stateBeforeSpecialEnd(c);
}
else if (this._state === 38 /* State.AfterScript1 */) {
else if (this._state === 39 /* State.AfterScript1 */) {
stateAfterScript1(this, c);
}
else if (this._state === 39 /* State.AfterScript2 */) {
else if (this._state === 40 /* State.AfterScript2 */) {
stateAfterScript2(this, c);
}
else if (this._state === 40 /* State.AfterScript3 */) {
else if (this._state === 41 /* State.AfterScript3 */) {
stateAfterScript3(this, c);
}
else if (this._state === 33 /* State.BeforeScript1 */) {
else if (this._state === 34 /* State.BeforeScript1 */) {
stateBeforeScript1(this, c);
}
else if (this._state === 34 /* State.BeforeScript2 */) {
else if (this._state === 35 /* State.BeforeScript2 */) {
stateBeforeScript2(this, c);
}
else if (this._state === 35 /* State.BeforeScript3 */) {
else if (this._state === 36 /* State.BeforeScript3 */) {
stateBeforeScript3(this, c);
}
else if (this._state === 36 /* State.BeforeScript4 */) {
else if (this._state === 37 /* State.BeforeScript4 */) {
stateBeforeScript4(this, c);
}
else if (this._state === 37 /* State.BeforeScript5 */) {
else if (this._state === 38 /* State.BeforeScript5 */) {
this._stateBeforeScript5(c);
}
else if (this._state === 41 /* State.AfterScript4 */) {
else if (this._state === 42 /* State.AfterScript4 */) {
stateAfterScript4(this, c);
}
else if (this._state === 42 /* State.AfterScript5 */) {
else if (this._state === 43 /* State.AfterScript5 */) {
this._stateAfterScript5(c);
}
else if (this._state === 43 /* State.BeforeStyle1 */) {
else if (this._state === 44 /* State.BeforeStyle1 */) {
stateBeforeStyle1(this, c);
}
else if (this._state === 28 /* State.InCdata */) {
else if (this._state === 29 /* State.InCdata */) {
this._stateInCdata(c);
}
else if (this._state === 44 /* State.BeforeStyle2 */) {
else if (this._state === 45 /* State.BeforeStyle2 */) {
stateBeforeStyle2(this, c);
}
else if (this._state === 45 /* State.BeforeStyle3 */) {
else if (this._state === 46 /* State.BeforeStyle3 */) {
stateBeforeStyle3(this, c);
}
else if (this._state === 46 /* State.BeforeStyle4 */) {
else if (this._state === 47 /* State.BeforeStyle4 */) {
this._stateBeforeStyle4(c);
}
else if (this._state === 47 /* State.AfterStyle1 */) {
else if (this._state === 48 /* State.AfterStyle1 */) {
stateAfterStyle1(this, c);
}
else if (this._state === 48 /* State.AfterStyle2 */) {
else if (this._state === 49 /* State.AfterStyle2 */) {
stateAfterStyle2(this, c);
}
else if (this._state === 49 /* State.AfterStyle3 */) {
else if (this._state === 50 /* State.AfterStyle3 */) {
stateAfterStyle3(this, c);
}
else if (this._state === 50 /* State.AfterStyle4 */) {
else if (this._state === 51 /* State.AfterStyle4 */) {
this._stateAfterStyle4(c);

@@ -736,39 +756,39 @@ }

}
else if (this._state === 53 /* State.InNamedEntity */) {
else if (this._state === 54 /* State.InNamedEntity */) {
this._stateInNamedEntity(c);
}
else if (this._state === 22 /* State.BeforeCdata1 */) {
else if (this._state === 23 /* State.BeforeCdata1 */) {
stateBeforeCdata1(this, c);
}
else if (this._state === 51 /* State.BeforeEntity */) {
else if (this._state === 52 /* State.BeforeEntity */) {
stateBeforeEntity(this, c);
}
else if (this._state === 23 /* State.BeforeCdata2 */) {
else if (this._state === 24 /* State.BeforeCdata2 */) {
stateBeforeCdata2(this, c);
}
else if (this._state === 24 /* State.BeforeCdata3 */) {
else if (this._state === 25 /* State.BeforeCdata3 */) {
stateBeforeCdata3(this, c);
}
else if (this._state === 29 /* State.AfterCdata1 */) {
else if (this._state === 30 /* State.AfterCdata1 */) {
this._stateAfterCdata1(c);
}
else if (this._state === 30 /* State.AfterCdata2 */) {
else if (this._state === 31 /* State.AfterCdata2 */) {
this._stateAfterCdata2(c);
}
else if (this._state === 25 /* State.BeforeCdata4 */) {
else if (this._state === 26 /* State.BeforeCdata4 */) {
stateBeforeCdata4(this, c);
}
else if (this._state === 26 /* State.BeforeCdata5 */) {
else if (this._state === 27 /* State.BeforeCdata5 */) {
stateBeforeCdata5(this, c);
}
else if (this._state === 27 /* State.BeforeCdata6 */) {
else if (this._state === 28 /* State.BeforeCdata6 */) {
this._stateBeforeCdata6(c);
}
else if (this._state === 55 /* State.InHexEntity */) {
else if (this._state === 56 /* State.InHexEntity */) {
this._stateInHexEntity(c);
}
else if (this._state === 54 /* State.InNumericEntity */) {
else if (this._state === 55 /* State.InNumericEntity */) {
this._stateInNumericEntity(c);
}
else if (this._state === 52 /* State.BeforeNumericEntity */) {
else if (this._state === 53 /* State.BeforeNumericEntity */) {
stateBeforeNumericEntity(this, c);

@@ -813,13 +833,13 @@ }

var data = this._buffer.substr(this._sectionStart);
if (this._state === 28 /* State.InCdata */ ||
this._state === 29 /* State.AfterCdata1 */ ||
this._state === 30 /* State.AfterCdata2 */) {
if (this._state === 29 /* State.InCdata */ ||
this._state === 30 /* State.AfterCdata1 */ ||
this._state === 31 /* State.AfterCdata2 */) {
this._cbs.oncdata(data);
}
else if (this._state === 19 /* State.InComment */ ||
this._state === 20 /* State.AfterComment1 */ ||
this._state === 21 /* State.AfterComment2 */) {
this._state === 21 /* State.AfterComment1 */ ||
this._state === 22 /* State.AfterComment2 */) {
this._cbs.oncomment(data);
}
else if (this._state === 53 /* State.InNamedEntity */ && !this._xmlMode) {
else if (this._state === 54 /* State.InNamedEntity */ && !this._xmlMode) {
this._parseLegacyEntity();

@@ -831,3 +851,3 @@ if (this._sectionStart < this._index) {

}
else if (this._state === 54 /* State.InNumericEntity */ && !this._xmlMode) {
else if (this._state === 55 /* State.InNumericEntity */ && !this._xmlMode) {
this._decodeNumericEntity(2, 10);

@@ -839,3 +859,3 @@ if (this._sectionStart < this._index) {

}
else if (this._state === 55 /* State.InHexEntity */ && !this._xmlMode) {
else if (this._state === 56 /* State.InHexEntity */ && !this._xmlMode) {
this._decodeNumericEntity(3, 16);

@@ -842,0 +862,0 @@ if (this._sectionStart < this._index) {

{
"name": "@joplin/fork-htmlparser2",
"description": "Fast & forgiving HTML/XML/RSS parser",
"version": "4.1.52",
"version": "4.1.53",
"author": "Felix Boehm <me@feedic.com>",

@@ -48,12 +48,12 @@ "publishConfig": {

"devDependencies": {
"@types/jest": "29.5.8",
"@types/node": "18.19.26",
"@typescript-eslint/eslint-plugin": "6.8.0",
"@typescript-eslint/parser": "6.8.0",
"@types/jest": "29.5.12",
"@types/node": "18.19.50",
"@typescript-eslint/eslint-plugin": "6.21.0",
"@typescript-eslint/parser": "6.21.0",
"coveralls": "3.1.1",
"eslint": "8.52.0",
"eslint": "8.57.0",
"jest": "29.7.0",
"prettier": "3.0.3",
"ts-jest": "29.1.1",
"typescript": "5.2.2"
"prettier": "3.3.2",
"ts-jest": "29.1.5",
"typescript": "5.4.5"
},

@@ -68,3 +68,3 @@ "jest": {

},
"gitHead": "a48c4ba93fb438c0dc190a61762f4bed44b946fe"
"gitHead": "189ba7795a8af01a6ffd3607c92a271d69b68783"
}

@@ -57,2 +57,4 @@ * * *

To fix an HTML parsing issue (tags were allowed to start with non-alphanumeric characters), [this upstream commit](https://github.com/fb55/htmlparser2/commit/bc010de9df09f2d730a69734e05e5175ea8bd2d7) has also been applied.
* * *

@@ -59,0 +61,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc