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

html-parser

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-parser - npm Package Compare versions

Comparing version 0.6.3 to 0.6.4

.npmignore

2

package.json
{
"name": "html-parser",
"version": "0.6.3",
"version": "0.6.4",
"description": "HTML/XML parser with less explosions",

@@ -5,0 +5,0 @@ "keywords": [ "html", "xml", "parser", "explosion" ],

@@ -295,2 +295,17 @@ var parseContext = require('./context');

var ignoring = false;
var selfClosingTags = {
meta: 1,
br: 1,
link: 1,
area: 1,
base :1,
col: 1,
command: 1,
embed: 1,
hr: 1,
img: 1,
input: 1,
param: 1,
source: 1
};
var callbacks = {

@@ -306,2 +321,15 @@ docType: function(value) {

name = name.toLowerCase();
//if there is an unclosed self-closing tag in the stack, then
//pop it off (assumed to be malformed html).
if (tagStack.length) {
var scope = tagStack[tagStack.length - 1];
//console.log(scope);
if (selfClosingTags[scope.name]) {
tagStack.pop();
if (scope === ignoring) {
ignoring = null;
}
}
}
tagStack.push({ name: name });

@@ -308,0 +336,0 @@ if (toRemove.elements(name)) {

@@ -120,2 +120,33 @@ var should = require('should');

});
describe('self-closing tags that don\'t close', function() {
var selfClosingTags = {
meta: 1,
br: 1,
link: 1,
area: 1,
base: 1,
col: 1,
command: 1,
embed: 1,
hr: 1,
img: 1,
input: 1,
param: 1,
source: 1
};
for (var tag in selfClosingTags) {
it(tag + ' tag without a "/>"', (function(tag) {
return function() {
var html = '<' + tag + '><p>foo</p>';
var sanitized = helpers.parser.sanitize(html, {
elements: [ tag ]
});
sanitized.should.equal('<p>foo</p>');
}
}(tag)));
}
});
});
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