Skip to content

Commit

Permalink
[tiff#187] adds style rule to check_attributes handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybee committed Oct 19, 2012
1 parent 4c18401 commit 9027cc0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/dom/parse.js
Expand Up @@ -411,6 +411,13 @@ wysihtml5.dom.parse = (function() {
attributeValue = (attributeValue || "").replace(REG_EXP, "");
return attributeValue || null;
};
})(),

style: (function() {
var REG_EXP = /[^a-z0-9_\-]\:[^a-z0-9_\-];/gi;
return function(attributeValue) {
return attributeValue;
};
})()
};

Expand Down
18 changes: 18 additions & 0 deletions test/dom/parse_test.js
Expand Up @@ -563,6 +563,24 @@ if (wysihtml5.browser.supported()) {
"'mailto:' urls are not stripped"
);
});

test("Check style attributes", function() {
var rules = {
tags: {
span: {
check_attributes: {
"style": "style"
}
}
}
};

this.equal(
this.sanitize('<span style="font-weight:bold">bar</span>', rules),
'<span style="font-weight:bold">bar</span>',
"custom style attributes are not stripped"
);
});

test("Check custom data attributes", function() {
var rules = {
Expand Down

0 comments on commit 9027cc0

Please sign in to comment.