New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

html-janitor

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-janitor - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

6

CHANGELOG.md

@@ -5,2 +5,8 @@ # HTML Janitor

## 2.0.2
Validation functions can now return validation objects rather than simply outcomes.
Thanks to [Brad Vogel](https://github.com/bradvogel) for this functionality.
## 2.0.1

@@ -7,0 +13,0 @@

2

package.json
{
"name": "html-janitor",
"version": "2.0.1",
"version": "2.0.2",
"main": "src/html-janitor.js",

@@ -5,0 +5,0 @@ "scripts": {

@@ -59,3 +59,16 @@ # html-janitor

Functions may return any value that's accepted as a regular value, including an object:
```
blockquote: function(el) {
if (el.classList.contains('indent')){
return { 'class': true, 'style': true }; // If blockquote has class 'indent', also allow style.
} else {
return {}; // Strip everything
}
}
```
## Distribution

@@ -62,0 +75,0 @@

@@ -101,4 +101,5 @@ (function (root, factory) {

var nodeName = node.nodeName.toLowerCase();
var allowedAttrs = this.config.tags[nodeName];
var allowedAttrs = getAllowedAttrs(this.config, nodeName, node);
var isInvalid = isInline && containsBlockElement;

@@ -147,7 +148,15 @@

function getAllowedAttrs(config, nodeName, node){
if (typeof config.tags[nodeName] === 'function') {
return config.tags[nodeName](node);
} else {
return config.tags[nodeName];
}
}
function shouldRejectNode(node, allowedAttrs){
if (typeof allowedAttrs === 'undefined') {
return true;
} else if (typeof allowedAttrs === 'function'){
return !allowedAttrs(node);
} else if (typeof allowedAttrs === 'boolean') {
return !allowedAttrs;
}

@@ -154,0 +163,0 @@

@@ -38,2 +38,10 @@ define([ 'html-janitor' ], function (HTMLJanitor) {

}
},
blockquote: function(el) {
// If blockquote has class 'indent', also allow style.
if (el.classList.contains('indent')){
return { 'class': true, 'style': true };
} else {
return {};
}
}

@@ -190,3 +198,3 @@ }

expect(output).toBe('<figure></figure>');
expect(output).toBe('');
});

@@ -217,2 +225,11 @@

});
it('should allow certain attributes', function() {
var html = '<blockquote class="indent" style="display:inline" notallowedattr="1"></blockquote>';
expect(janitor.clean(html)).toBe('<blockquote class="indent" style="display:inline"></blockquote>');
html = '<blockquote style="display:inline"></blockquote>';
expect(janitor.clean(html)).toBe('<blockquote></blockquote>');
});
});

@@ -219,0 +236,0 @@

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