Socket
Socket
Sign inDemoInstall

htmlparser2

Package Overview
Dependencies
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

htmlparser2 - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

htmlparser2.esproj/Project.espressostorage

42

lib/Parser.js

@@ -10,2 +10,3 @@ var ElementType = require("./ElementType.js");

this._stack = [];
this._wroteSpecial = false;
this._contentFlags = 0;

@@ -17,8 +18,8 @@ this._done = false;

//Regular expressions used for cleaning up and parsing (stateless)
var _reTagName = /[^\s\/]+/; //matches tagnames
var _reTagName = /[^\s\/]+/; //matches tag names
var _reAttrib = /([^=<>\"\'\s]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^'"\s]+))|([^=<>\"\'\s\/]+)/g;
Parser.prototype._options = {
xmlMode: false, //Special behaviour for script/style tags by default
lowerCaseTags: false //call .toLowerCase for each tagname
xmlMode: false, //Special behavior for script/style tags by default
lowerCaseTags: false //call .toLowerCase for each tag name
};

@@ -103,9 +104,8 @@

//Special tags that are threated differently
//Special tags that are treated differently
var SpecialTags = {};
SpecialTags[ElementType.Tag] = 0;
//SpecialTags[ElementType.Tag] = 0;
SpecialTags[ElementType.Style] = 1; //2^0
SpecialTags[ElementType.Script] = 2; //2^1
SpecialTags.w = 4; //2^2 - if set, append prev tag sep to data
SpecialTags[ElementType.Comment] = 8; //2^3
SpecialTags[ElementType.Comment] = 4; //2^3

@@ -154,9 +154,9 @@ //Parses through HTML text and returns an array of found elements

//if it's a closing tag, remove the flag
if(this._contentFlags >= SpecialTags[ElementType.Script] && elementData === "script"){
//remove the script flag (also removes the written flag)
this._contentFlags %= SpecialTags[ElementType.Script];
if(this._contentFlags === SpecialTags[ElementType.Script] && elementData === "script"){
//remove the script flag
this._contentFlags -= SpecialTags[ElementType.Script];
}
else if(this._contentFlags >= SpecialTags[ElementType.Style] && elementData === "style"){
//remove the style flag (also removes the written flag)
this._contentFlags %= SpecialTags[ElementType.Style];
else if(this._contentFlags === SpecialTags[ElementType.Style] && elementData === "style"){
//remove the style flag
this._contentFlags -= SpecialTags[ElementType.Style];
}

@@ -176,5 +176,3 @@ else {

}
else if(this._contentFlags !== 0){
this._writeSpecial(rawData, lastTagSep);
}
else if(this._contentFlags !== 0) this._writeSpecial(rawData, lastTagSep);
//This tag is a directive

@@ -208,3 +206,4 @@ //TODO: what about CDATA?

//remove the written flag (also removes the comment flag)
this._contentFlags %= SpecialTags.w;
this._contentFlags -= SpecialTags[ElementType.Comment];
this._wroteSpecial = false;
if(this._cbs.oncomment) this._cbs.oncomment(rawData.slice(0, -2));

@@ -218,7 +217,7 @@ if(this._cbs.oncommentend) this._cbs.oncommentend();

//if the previous element is text, append the last tag sep to element
if(this._contentFlags >= SpecialTags.w){
if(this._wroteSpecial){
if(this._cbs.ontext) this._cbs.ontext(lastTagSep + rawData);
}
else{ //The previous element was not text
this._contentFlags += SpecialTags.w;
this._wroteSpecial = true;
if(rawData !== "" && this._cbs.ontext) this._cbs.ontext(rawData);

@@ -260,3 +259,6 @@ }

} else {
this._contentFlags += SpecialTags[type];
if(type !== ElementType.Tag){
this._contentFlags += SpecialTags[type];
this._wroteSpecial = false;
}
this._stack.push(name);

@@ -263,0 +265,0 @@ }

{
"name": "htmlparser2",
"description": "Forgiving HTML/XML/RSS Parser for Node. This version is optimised and cleaned and provides a SAX interface.",
"version": "2.1.0",
"version": "2.1.1",
"author": "Felix Boehm <me@feedic.com>",

@@ -22,5 +22,3 @@ "contributors": ["Chris Winberry <chris@winberry.net>"],

},
"engines": {
"node": ">0"
},
"engines": "node >= 0.3.0",
"licenses": [{

@@ -27,0 +25,0 @@ "type": "MIT",

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