Skip to content

Commit

Permalink
Fix embedded code being removed
Browse files Browse the repository at this point in the history
no issue
- changed order of escaping
  • Loading branch information
sebgie committed Aug 5, 2014
1 parent 954fde1 commit aec440b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions core/client/helpers/gh-format-markdown.js
Expand Up @@ -4,20 +4,20 @@ import cajaSanitizers from 'ghost/utils/caja-sanitizers';
var showdown = new Showdown.converter({extensions: ['ghostimagepreview', 'ghostgfm']});

var formatMarkdown = Ember.Handlebars.makeBoundHelper(function (markdown) {
var html = '';
var escapedhtml = '';

// convert markdown to HTML
escapedhtml = showdown.makeHtml(markdown || '');

// replace script and iFrame
markdown = markdown.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
escapedhtml = escapedhtml.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
'<pre class="js-embed-placeholder">Embedded JavaScript</pre>');
markdown = markdown.replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
escapedhtml = escapedhtml.replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
'<pre class="iframe-embed-placeholder">Embedded iFrame</pre>');

// convert markdown to HTML
html = showdown.makeHtml(markdown || '');

// sanitize html
html = html_sanitize(html, cajaSanitizers.url, cajaSanitizers.id);
return new Handlebars.SafeString(html);
escapedhtml = html_sanitize(escapedhtml, cajaSanitizers.url, cajaSanitizers.id);
return new Handlebars.SafeString(escapedhtml);
});

export default formatMarkdown;

0 comments on commit aec440b

Please sign in to comment.