mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 02:11:44 +03:00
9997d3aaf1
no issue - changed order of escaping
23 lines
941 B
JavaScript
23 lines
941 B
JavaScript
/* global Showdown, Handlebars, html_sanitize*/
|
|
import cajaSanitizers from 'ghost/utils/caja-sanitizers';
|
|
|
|
var showdown = new Showdown.converter({extensions: ['ghostimagepreview', 'ghostgfm']});
|
|
|
|
var formatMarkdown = Ember.Handlebars.makeBoundHelper(function (markdown) {
|
|
var escapedhtml = '';
|
|
|
|
// convert markdown to HTML
|
|
escapedhtml = showdown.makeHtml(markdown || '');
|
|
|
|
// replace script and iFrame
|
|
escapedhtml = escapedhtml.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
|
|
'<pre class="js-embed-placeholder">Embedded JavaScript</pre>');
|
|
escapedhtml = escapedhtml.replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
|
|
'<pre class="iframe-embed-placeholder">Embedded iFrame</pre>');
|
|
|
|
// sanitize html
|
|
escapedhtml = html_sanitize(escapedhtml, cajaSanitizers.url, cajaSanitizers.id);
|
|
return new Handlebars.SafeString(escapedhtml);
|
|
});
|
|
|
|
export default formatMarkdown; |