From ff0da365e890ee21d41881205f56417cfa7d7f6a Mon Sep 17 00:00:00 2001 From: Helder Sepulveda Date: Mon, 5 Feb 2018 20:52:34 -0500 Subject: [PATCH 1/2] Add a couple of items to the sanitizeOptions --- src/core/components/providers/markdown.jsx | 6 ++++-- test/components/markdown.js | 12 ++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/core/components/providers/markdown.jsx b/src/core/components/providers/markdown.jsx index 35ad0c5fc09..ad4f40b9dd5 100644 --- a/src/core/components/providers/markdown.jsx +++ b/src/core/components/providers/markdown.jsx @@ -29,10 +29,12 @@ Markdown.propTypes = { export default Markdown const sanitizeOptions = { - allowedTags: sanitize.defaults.allowedTags.concat([ "h1", "h2", "img" ]), + allowedTags: sanitize.defaults.allowedTags.concat([ "h1", "h2", "img", "span" ]), allowedAttributes: { ...sanitize.defaults.allowedAttributes, - "img": sanitize.defaults.allowedAttributes.img.concat(["title"]) + "img": sanitize.defaults.allowedAttributes.img.concat(["title"]), + 'td': [ 'colspan' ], + '*': [ 'class' ] }, textFilter: function(text) { return text.replace(/"/g, "\"") diff --git a/test/components/markdown.js b/test/components/markdown.js index 65b80c0ecd5..c3a716a3f46 100644 --- a/test/components/markdown.js +++ b/test/components/markdown.js @@ -7,6 +7,18 @@ import { Markdown as OAS3Markdown } from "corePlugins/oas3/wrap-components/markd describe("Markdown component", function() { describe("Swagger 2.0", function() { + it("allows span elements with class attrib", function() { + const str = `ONE` + const el = render() + expect(el.html()).toEqual(`

ONE

\n
`) + }) + + it("allows td elements with colspan attrib", function() { + const str = `
ABC
` + const el = render() + expect(el.html()).toEqual(`
ABC
`) + }) + it("allows image elements", function() { const str = `![Image alt text](http://image.source "Image title")` const el = render() From 5f4e09cc80face62b85f724d45fceee6e681ca3c Mon Sep 17 00:00:00 2001 From: Helder Sepulveda Date: Mon, 5 Feb 2018 21:17:54 -0500 Subject: [PATCH 2/2] Strings must use doublequote quotes --- src/core/components/providers/markdown.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/components/providers/markdown.jsx b/src/core/components/providers/markdown.jsx index ad4f40b9dd5..ec096d5f8b1 100644 --- a/src/core/components/providers/markdown.jsx +++ b/src/core/components/providers/markdown.jsx @@ -33,8 +33,8 @@ const sanitizeOptions = { allowedAttributes: { ...sanitize.defaults.allowedAttributes, "img": sanitize.defaults.allowedAttributes.img.concat(["title"]), - 'td': [ 'colspan' ], - '*': [ 'class' ] + "td": [ "colspan" ], + "*": [ "class" ] }, textFilter: function(text) { return text.replace(/"/g, "\"")