File size: 1,253 Bytes
eb67da4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
const MdToHtml = require('./MdToHtml'); const HtmlToHtml = require('./HtmlToHtml'); class MarkupToHtml { constructor(options) { this.options_ = Object.assign({}, { ResourceModel: { isResourceUrl: () => false, }, }, options); this.renderers_ = {}; } renderer(markupLanguage) { if (this.renderers_[markupLanguage]) return this.renderers_[markupLanguage]; let RendererClass = null; if (markupLanguage === MarkupToHtml.MARKUP_LANGUAGE_MARKDOWN) { RendererClass = MdToHtml; } else if (markupLanguage === MarkupToHtml.MARKUP_LANGUAGE_HTML) { RendererClass = HtmlToHtml; } else { throw new Error(`Invalid markup language: ${markupLanguage}`); } this.renderers_[markupLanguage] = new RendererClass(this.options_); return this.renderers_[markupLanguage]; } injectedJavaScript() { return ''; } // BUG: CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') // render(markupLanguage, markup, theme, options) { // FIXED: async render(markupLanguage, markup, theme, options) { return this.renderer(markupLanguage).render(markup, theme, options); } } MarkupToHtml.MARKUP_LANGUAGE_MARKDOWN = 1; MarkupToHtml.MARKUP_LANGUAGE_HTML = 2; module.exports = MarkupToHtml; |