From 9027cc0bdc73a3ef3ea66100bd528780aad7a630 Mon Sep 17 00:00:00 2001 From: Jonathan Barrett Date: Fri, 19 Oct 2012 10:06:40 +0100 Subject: [PATCH] [#187] adds style rule to check_attributes handling --- src/dom/parse.js | 7 +++++++ test/dom/parse_test.js | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/dom/parse.js b/src/dom/parse.js index d2bdc998..53d145f7 100644 --- a/src/dom/parse.js +++ b/src/dom/parse.js @@ -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; + }; })() }; diff --git a/test/dom/parse_test.js b/test/dom/parse_test.js index 244dcd5d..7823d491 100644 --- a/test/dom/parse_test.js +++ b/test/dom/parse_test.js @@ -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('bar', rules), + 'bar', + "custom style attributes are not stripped" + ); + }); test("Check custom data attributes", function() { var rules = {