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

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.2.9 to 2.3.0

3

lib/DomHandler.js

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

DomHandler.prototype.onclosetag = function(name){
if(this._tagStack.pop().name !== name) this._handleCallback(Error("Tagname didn't match!"));
//if(this._tagStack.pop().name !== name) this._handleCallback(Error("Tagname didn't match!"));
this._tagStack.pop();
};

@@ -42,0 +43,0 @@

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

if(type === ElementType.Comment) return "<!--" + elem.data + "-->";
if(type === ElementType.Directive) return "<" + elem.data + ">";

@@ -131,0 +132,0 @@ var ret = "<" + name;

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

xmlMode: false, //Special behavior for script/style tags by default
lowerCaseAttributeNames: false, //call .toLowerCase for each attribute name
lowerCaseTags: false //call .toLowerCase for each tag name

@@ -167,4 +168,3 @@ };

this._contentFlags ^= TagValues[elementData];
}
else {
} else {
this._writeSpecial(rawData, lastTagSep);

@@ -191,3 +191,3 @@ continue;

this._cbs.onprocessinginstruction(
"!" + this._parseTagName(elementData.substr(1)),
"!" + this._parseTagName(elementData.substr(1)),
elementData

@@ -201,3 +201,3 @@ );

this._cbs.onprocessinginstruction(
"?" + this._parseTagName(elementData.substr(1)),
"?" + this._parseTagName(elementData.substr(1)),
elementData

@@ -226,7 +226,7 @@ );

// CDATA ends
if(data.length !== 2 && this._cbs.ontext){
this._cbs.ontext(data.slice(0,-2));
}
this._contentFlags ^= SpecialTags[ElementType.CDATA];
if(this._cbs.oncdataend) this._cbs.oncdataend();
if(data.length !== 2 && this._cbs.ontext){
this._cbs.ontext(data.slice(0,-2));
}
this._contentFlags ^= SpecialTags[ElementType.CDATA];
if(this._cbs.oncdataend) this._cbs.oncdataend();
}

@@ -250,7 +250,7 @@ else if(this._cbs.ontext) this._cbs.ontext(data + this._tagSep);

if(this._wroteSpecial){
if(this._cbs.ontext) this._cbs.ontext(lastTagSep + rawData);
if(this._cbs.ontext) this._cbs.ontext(lastTagSep + rawData);
}
else{ //The previous element was not text
this._wroteSpecial = true;
if(rawData !== "" && this._cbs.ontext) this._cbs.ontext(rawData);
this._wroteSpecial = true;
if(rawData !== "" && this._cbs.ontext) this._cbs.ontext(rawData);
}

@@ -293,5 +293,5 @@ };

Parser.prototype._parseAttributes = function(data){
Parser.prototype._parseAttributes = function(data, lcNames){
for(var match; match = _reAttrib.exec(data);){
this._cbs.onattribute(match[1], match[2] || match[3] || match[4] || "");
this._cbs.onattribute(lcNames ? match[1].toLowerCase() : match[1], match[2] || match[3] || match[4] || "");
}

@@ -301,6 +301,6 @@ };

//parses the attribute string
var parseAttributes = function(data){
var parseAttributes = function(data, lcNames){
var attrs = {};
for(var match; match = _reAttrib.exec(data);){
attrs[match[1]] = match[2] || match[3] || match[4] || "";
attrs[lcNames ? match[1].toLowerCase() : match[1]] = match[2] || match[3] || match[4] || "";
}

@@ -319,4 +319,10 @@ return attrs;

if(this._cbs.onopentagname) this._cbs.onopentagname(name);
if(this._cbs.onopentag) this._cbs.onopentag(name, parseAttributes(data));
if(this._cbs.onattribute) this._parseAttributes(data);
if(this._cbs.onopentag){
this._cbs.onopentag(name, parseAttributes(
data, this._options.lowerCaseAttributeNames
));
}
if(this._cbs.onattribute){
this._parseAttributes(data, this._options.lowerCaseAttributeNames);
}

@@ -329,3 +335,3 @@ //If tag self-terminates, add an explicit, separate closing tag

this._contentFlags |= SpecialTags[type];
this._wroteSpecial = false;
this._wroteSpecial = false;
}

@@ -332,0 +338,0 @@ this._stack.push(name);

@@ -18,22 +18,16 @@ var WritableStream = require("./WritableStream.js");

Object.keys(EVENTS).forEach(function(name){
switch(EVENTS[name]){
case 0:{
cbs.prototype["on" + name] = function(){
this.scope.emit(name);
};
break;
}
case 1:{
cbs.prototype["on" + name] = function(a){
this.scope.emit(name, a);
};
break;
}
case 2:{
cbs.prototype["on" + name] = function(a, b){
this.scope.emit(name, a, b);
};
break;
}
default: throw Error("wrong number of arguments!");
if(EVENTS[name] === 0){
cbs.prototype["on" + name] = function(){
this.scope.emit(name);
};
} else if(EVENTS[name] === 1){
cbs.prototype["on" + name] = function(a){
this.scope.emit(name, a);
};
} else if(EVENTS[name] === 2){
cbs.prototype["on" + name] = function(a, b){
this.scope.emit(name, a, b);
};
} else {
throw Error("wrong number of arguments!");
}

@@ -40,0 +34,0 @@ });

{
"name": "htmlparser2",
"description": "Performance-optimized forgiving HTML/XML/RSS parser",
"version": "2.2.9",
"version": "2.3.0",
"author": "Felix Boehm <me@feedic.com>",

@@ -6,0 +6,0 @@ "keywords": ["html", "parser", "streams", "xml", "dom", "rss", "feed", "atom"],

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