Huge News!Announcing our $40M Series B led by Abstract Ventures.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 1.0.1 to 1.1.0

8

CHANGELOG.md

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

## 1.1.0
It should be possible to allow all attributes on an element. This was mentioned in the documentation but was not working as intended.
As the previous behaviour was broken I don't believe anyone was using it but if you were then hopefully it will just magically work for you now.
Thanks [Alex Palaistras](https://github.com/deuill) for fixing this.
## 1.0.1

@@ -7,0 +15,0 @@

1

example.js

@@ -13,3 +13,4 @@ require({

p.setAttribute('bar', 'baz');
p.setAttribute('foo', 'fighter');
console.log(janitor.clean(p.outerHTML));
});

2

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

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

@@ -12,3 +12,3 @@ # html-janitor

```
var janitor = HTMLJanitor(options);
var janitor = new HTMLJanitor(options);

@@ -50,2 +50,2 @@ var sanitisedHtml = janitor.clean(html);

npm run test
```
```

@@ -114,3 +114,3 @@ (function (root, factory) {

// Allow attribute?
var allowedAttrValue = allowedAttrs[attrName];
var allowedAttrValue = allowedAttrs[attrName] || allowedAttrs === true;
var notInAttrList = ! allowedAttrValue;

@@ -117,0 +117,0 @@ var valueNotAllowed = allowedAttrValue !== true && attr.value !== allowedAttrValue;

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

li: {},
small: true,
div: {}

@@ -145,2 +146,25 @@ }

it('should allow all attributes for elements with catch-all whitelist', function () {
var el = document.createElement('small');
el.setAttribute('data-test', 'true');
el.setAttribute('title', 'test');
var outputEl = document.createElement('div');
outputEl.innerHTML = janitor.clean(el.outerHTML);
var output = outputEl.children[0];
expect(output.tagName).toBe('SMALL');
var attributes = output.attributes;
expect(attributes.getNamedItem('data-test').name).toBe('data-test');
expect(attributes.getNamedItem('data-test').value).toBe('true');
expect(attributes.getNamedItem('title').name).toBe('title');
expect(attributes.getNamedItem('title').value).toBe('test');
});
});

@@ -147,0 +171,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