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

Commit cbcf088

Browse files
committed
Merge pull request #5 from neraliu/code-enhancement
minor enhancement of the code and increase code coverage to 100%
2 parents 0f7304b + 61aa76f commit cbcf088

2 files changed

Lines changed: 21 additions & 24 deletions

File tree

src/html-purify.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ See the accompanying LICENSE file for terms.
2525
this.cssParser = new CssParser({"ver": "strict", "throwError": false});
2626
}
2727

28+
// TODO: introduce polyfill for Array.indexOf
2829
function contains(arr, element) {
2930
for (var i = 0, len = arr.length; i < len; i++) {
3031
if (arr[i] === element) {
@@ -49,14 +50,11 @@ See the accompanying LICENSE file for terms.
4950
case 1:
5051
this.output += ch;
5152
break;
53+
5254
case 2:
53-
if (prevState === 35) {
54-
this.attrVals[attributeName] = attributeValue;
55-
}
56-
if (prevState === 36) {
57-
this.attrVals[attributeName] = attributeValue;
58-
}
59-
if (prevState === 40) {
55+
if (prevState === 35 ||
56+
prevState === 36 ||
57+
prevState === 40) {
6058
this.attrVals[attributeName] = attributeValue;
6159
}
6260

src/tag-attr-list.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ Whitelist.Tags = [
121121
"wbr"
122122
];
123123

124-
125124
Whitelist.Attributes = [
126125
"ept",
127126
"acceptCharset",
@@ -222,22 +221,22 @@ Whitelist.Attributes = [
222221
];
223222

224223
Whitelist.HrefAttributes = [
225-
"action",
226-
"background",
227-
"codebase",
228-
"cite",
229-
"classid",
230-
"formaction",
231-
"folder",
232-
"href",
233-
"icon",
234-
"longdesc",
235-
"manifest",
236-
"profile",
237-
"poster",
238-
"src",
239-
"usemap",
240-
"xlink:href"
224+
"action",
225+
"background",
226+
"codebase",
227+
"cite",
228+
"classid",
229+
"formaction",
230+
"folder",
231+
"href",
232+
"icon",
233+
"longdesc",
234+
"manifest",
235+
"profile",
236+
"poster",
237+
"src",
238+
"usemap",
239+
"xlink:href"
241240
];
242241

243242
module.exports = Whitelist;

0 commit comments

Comments
 (0)