Socket
Socket
Sign inDemoInstall

htmlparser2

Package Overview
Dependencies
8
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.2.5 to 3.3.0

test/Events/22-double_brackets.json

41

lib/FeedHandler.js

@@ -6,4 +6,4 @@ var index = require("./index.js"),

//TODO: make this a streamable handler
function FeedHandler(callback){
this.init(callback, { ignoreWhitespace: true });
function FeedHandler(callback, options){
this.init(callback, options);
}

@@ -24,5 +24,10 @@

DomUtils.getElementsByTagName(what, where, recurse, 1)
);
).trim();
}
function addConditionally(obj, prop, what, where, recurse){
var tmp = fetch(what, where, recurse);
if(tmp) obj[prop] = tmp;
}
var isValidFeed = function(value) {

@@ -42,8 +47,8 @@ return value === "rss" || value === "feed" || value === "rdf:RDF";

feed.type = "atom";
if(tmp = fetch("id", childs)) feed.id = tmp;
if(tmp = fetch("title", childs)) feed.title = tmp;
addConditionally(feed, "id", "id", childs);
addConditionally(feed, "title", "title", childs);
if((tmp = getOneElement("link", childs)) && (tmp = tmp.attribs) && (tmp = tmp.href)) feed.link = tmp;
if(tmp = fetch("subtitle", childs)) feed.description = tmp;
addConditionally(feed, "description", "subtitle", childs);
if(tmp = fetch("updated", childs)) feed.updated = new Date(tmp);
if(tmp = fetch("email", childs, true)) feed.author = tmp;
addConditionally(feed, "author", "email", childs, true);

@@ -55,6 +60,6 @@ feed.items = getElements("entry", childs).map(function(item){

if(tmp = fetch("id", item)) entry.id = tmp;
if(tmp = fetch("title", item)) entry.title = tmp;
addConditionally(entry, "id", "id", item);
addConditionally(entry, "title", "title", item);
if((tmp = getOneElement("link", item)) && (tmp = tmp.attribs) && (tmp = tmp.href)) entry.link = tmp;
if(tmp = fetch("summary", item)) entry.description = tmp;
addConditionally(entry, "description", "summary", item);
if(tmp = fetch("updated", item)) entry.pubDate = new Date(tmp);

@@ -68,7 +73,7 @@ return entry;

feed.id = "";
if(tmp = fetch("title", childs)) feed.title = tmp;
if(tmp = fetch("link", childs)) feed.link = tmp;
if(tmp = fetch("description", childs)) feed.description = tmp;
addConditionally(feed, "title", "title", childs);
addConditionally(feed, "link", "link", childs);
addConditionally(feed, "description", "description", childs);
if(tmp = fetch("lastBuildDate", childs)) feed.updated = new Date(tmp);
if(tmp = fetch("managingEditor", childs)) feed.author = tmp;
addConditionally(feed, "author", "managingEditor", childs, true);

@@ -80,6 +85,6 @@ feed.items = getElements("item", feedRoot.children).map(function(item){

if(tmp = fetch("guid", item)) entry.id = tmp;
if(tmp = fetch("title", item)) entry.title = tmp;
if(tmp = fetch("link", item)) entry.link = tmp;
if(tmp = fetch("description", item)) entry.description = tmp;
addConditionally(entry, "id", "guid", item);
addConditionally(entry, "title", "title", item);
addConditionally(entry, "link", "link", item);
addConditionally(entry, "description", "description", item);
if(tmp = fetch("pubDate", item)) entry.pubDate = new Date(tmp);

@@ -86,0 +91,0 @@ return entry;

{
"name": "htmlparser2",
"description": "Fast & forgiving HTML/XML/RSS parser",
"version": "3.2.5",
"version": "3.3.0",
"author": "Felix Boehm <me@feedic.com>",

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

"dependencies": {
"domhandler": "2.0",
"domhandler": "2.1",
"domutils": "1.1",

@@ -27,0 +27,0 @@ "domelementtype": "1",

@@ -10,12 +10,12 @@ exports.name = "RDF test";

{
"title": " Music Equipment Repair and Consignment ",
"link": "\nhttp://sfbay.craigslist.org/sby/muc/2681301534.html\n",
"description": "\nSan Jose Rock Shop offers musical instrument repair and consignment! (408) 215-2065<br> <br> We are pleased to announce our NEW LOCATION: 1199 N 5th st. San Jose, ca 95112. Please call ahead, by appointment only.<br> <br> Recently featured by Metro Newspaper in their 2011 Best of the Silicon Valley edition see it online here:<br> <a href=\"http://www.metroactive.com/best-of-silicon-valley/2011/music-nightlife/editor-picks.html\" rel=\"nofollow\">http://www.metroactive.com/best-of-silicon-valley/2011/music-nightlife/editor-picks.html</a><br> <br> Guitar Set up (acoustic and electronic) $40!<!-- END CLTAGS -->\n"
"title": "Music Equipment Repair and Consignment",
"link": "http://sfbay.craigslist.org/sby/muc/2681301534.html",
"description": "San Jose Rock Shop offers musical instrument repair and consignment! (408) 215-2065<br> <br> We are pleased to announce our NEW LOCATION: 1199 N 5th st. San Jose, ca 95112. Please call ahead, by appointment only.<br> <br> Recently featured by Metro Newspaper in their 2011 Best of the Silicon Valley edition see it online here:<br> <a href=\"http://www.metroactive.com/best-of-silicon-valley/2011/music-nightlife/editor-picks.html\" rel=\"nofollow\">http://www.metroactive.com/best-of-silicon-valley/2011/music-nightlife/editor-picks.html</a><br> <br> Guitar Set up (acoustic and electronic) $40!<!-- END CLTAGS -->"
},
{
"title": "\nRide Offered - Oakland/BART to LA/SFV - TODAY 3PM 11/04 (oakland north / temescal)\n",
"link": "\nhttp://sfbay.craigslist.org/eby/rid/2685010755.html\n",
"description": "\nIm offering a lift for up to two people from Oakland (or near any BART station in the East Bay/580/880 Corridor, or San Jose/Morgan Hill, Gilroy) to the San Fernando Valley / Los Angeles area. Specifically, Im leaving from Oakland between 2:30 and 3:00pm (this is flexible, but if I leave too late my girlfriend will kill me), and heading to Woodland Hills via the 580, I-5, 405, and 101.<!-- END CLTAGS -->\n"
"title": "Ride Offered - Oakland/BART to LA/SFV - TODAY 3PM 11/04 (oakland north / temescal)",
"link": "http://sfbay.craigslist.org/eby/rid/2685010755.html",
"description": "Im offering a lift for up to two people from Oakland (or near any BART station in the East Bay/580/880 Corridor, or San Jose/Morgan Hill, Gilroy) to the San Fernando Valley / Los Angeles area. Specifically, Im leaving from Oakland between 2:30 and 3:00pm (this is flexible, but if I leave too late my girlfriend will kill me), and heading to Woodland Hills via the 580, I-5, 405, and 101.<!-- END CLTAGS -->"
}
]
};

@@ -6,4 +6,3 @@ var htmlparser2 = require(".."),

Parser = htmlparser2.Parser,
CollectingHandler = htmlparser2.CollectingHandler,
chunkSize = 5;
CollectingHandler = htmlparser2.CollectingHandler;

@@ -13,4 +12,4 @@ exports.writeToParser = function(handler, options, data){

//first, try to run the test via chunks
for(var i = 0; i < data.length; i += chunkSize){
parser.write(data.substr(i, chunkSize));
for(var i = 0; i < data.length; i++){
parser.write(data.charAt(i));
}

@@ -17,0 +16,0 @@ parser.end();

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc