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

Commit

Permalink
Merge pull request #5 from neraliu/code-enhancement
Browse files Browse the repository at this point in the history
minor enhancement of the code and increase code coverage to 100%
  • Loading branch information
maditya committed Jun 26, 2015
2 parents 0f7304b + 61aa76f commit cbcf088
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 24 deletions.
12 changes: 5 additions & 7 deletions src/html-purify.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ See the accompanying LICENSE file for terms.
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 @@ -49,14 +50,11 @@ See the accompanying LICENSE file for terms.
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
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 cbcf088

Please sign in to comment.