From aec440bbd0bc27bb3dd1bf45722da06fb9962c6f Mon Sep 17 00:00:00 2001 From: Sebastian Gierlinger Date: Tue, 5 Aug 2014 14:11:20 +0200 Subject: [PATCH] Fix embedded code being removed no issue - changed order of escaping --- core/client/helpers/gh-format-markdown.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/core/client/helpers/gh-format-markdown.js b/core/client/helpers/gh-format-markdown.js index 1311438f76..1a04ca6f7a 100644 --- a/core/client/helpers/gh-format-markdown.js +++ b/core/client/helpers/gh-format-markdown.js @@ -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 = ''; - - // replace script and iFrame - markdown = markdown.replace(/)<[^<]*)*<\/script>/gi, - '
Embedded JavaScript
'); - markdown = markdown.replace(/)<[^<]*)*<\/iframe>/gi, - '
Embedded iFrame
'); + var escapedhtml = ''; // convert markdown to HTML - html = showdown.makeHtml(markdown || ''); + escapedhtml = showdown.makeHtml(markdown || ''); + + // replace script and iFrame + escapedhtml = escapedhtml.replace(/)<[^<]*)*<\/script>/gi, + '
Embedded JavaScript
'); + escapedhtml = escapedhtml.replace(/)<[^<]*)*<\/iframe>/gi, + '
Embedded iFrame
'); // 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; \ No newline at end of file