Skip to content
This repository has been archived by the owner on Jul 15, 2019. It is now read-only.

Commit

Permalink
minor enhancement of the code and increase code coverage to 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
neraliu committed Jun 24, 2015
1 parent 02b2cee commit 61aa76f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 25 deletions.
13 changes: 5 additions & 8 deletions src/html-purify.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var CssParser = require('css-js');
this.cssParser = new CssParser({"ver": "strict", "throwError": false});
}

// TODO: introduce polyfill for Array.indexOf
function contains(arr, element) {
for (var i = 0, len = arr.length; i < len; i++) {
if (arr[i] === element) {
Expand All @@ -55,14 +56,11 @@ var CssParser = require('css-js');
case 1:
this.output += ch;
break;

case 2:
if (prevState === 35) {
this.attrVals[attributeName] = attributeValue;
}
if (prevState === 36) {
this.attrVals[attributeName] = attributeValue;
}
if (prevState === 40) {
if (prevState === 35 ||
prevState === 36 ||
prevState === 40) {
this.attrVals[attributeName] = attributeValue;
}

Expand Down Expand Up @@ -121,7 +119,6 @@ var CssParser = require('css-js');
}
}


Purifier.prototype.purify = function (data) {
this.output = '';
this.attrVals = {};
Expand Down
33 changes: 16 additions & 17 deletions src/tag-attr-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ Whitelist.Tags = [
"wbr"
];


Whitelist.Attributes = [
"ept",
"acceptCharset",
Expand Down Expand Up @@ -222,22 +221,22 @@ Whitelist.Attributes = [
];

Whitelist.HrefAttributes = [
"action",
"background",
"codebase",
"cite",
"classid",
"formaction",
"folder",
"href",
"icon",
"longdesc",
"manifest",
"profile",
"poster",
"src",
"usemap",
"xlink:href"
"action",
"background",
"codebase",
"cite",
"classid",
"formaction",
"folder",
"href",
"icon",
"longdesc",
"manifest",
"profile",
"poster",
"src",
"usemap",
"xlink:href"
];

module.exports = Whitelist;

0 comments on commit 61aa76f

Please sign in to comment.