* set new bundlesize goal * preserve `GeneratorFunction` instead of all function names * use js-yaml fork that doesn't require esprima * set HTML content directly, instead of using React-Markdown * use remarkable for all Markdown rendering * add babel-plugin-transform-react-remove-prop-types * remove SplitPaneMode plugin * remove react-collapse * remove AST plugin, and yaml-js * trim Markdown HTML string output before rendering * disable obsolete function name preservation * add `getComponent` to propTypes
37 lines
1.4 KiB
JavaScript
37 lines
1.4 KiB
JavaScript
/* eslint-env mocha */
|
|
import React from "react"
|
|
import expect from "expect"
|
|
import { render } from "enzyme"
|
|
import Markdown from "components/providers/markdown"
|
|
import { Markdown as OAS3Markdown } from "corePlugins/oas3/wrap-components/markdown.js"
|
|
|
|
describe("Markdown Script Sanitization", function() {
|
|
describe("Swagger 2.0", function() {
|
|
it("sanitizes <script> elements", function() {
|
|
const str = `script <script>alert(1)</script>`
|
|
const el = render(<Markdown source={str} />)
|
|
expect(el.html()).toEqual(`<div class="markdown"><p>script </p>\n</div>`)
|
|
})
|
|
|
|
it("sanitizes <img> elements", function() {
|
|
const str = `<img src=x onerror="alert('img-in-description')">`
|
|
const el = render(<Markdown source={str} />)
|
|
expect(el.html()).toEqual(`<div class="markdown"><p><img src="x"></p>\n</div>`)
|
|
})
|
|
})
|
|
|
|
describe("OAS 3", function() {
|
|
it("sanitizes <script> elements", function() {
|
|
const str = `script <script>alert(1)</script>`
|
|
const el = render(<OAS3Markdown source={str} />)
|
|
expect(el.html()).toEqual(`<div class="renderedMarkdown"><p>script </p></div>`)
|
|
})
|
|
|
|
it("sanitizes <img> elements", function() {
|
|
const str = `<img src=x onerror="alert('img-in-description')">`
|
|
const el = render(<OAS3Markdown source={str} />)
|
|
expect(el.html()).toEqual(`<div class="renderedMarkdown"><p><img src="x"></p></div>`)
|
|
})
|
|
})
|
|
})
|