2014-07-25 14:42:42 +04:00
|
|
|
/* global Handlebars, html_sanitize*/
|
|
|
|
import cajaSanitizers from 'ghost/utils/caja-sanitizers';
|
|
|
|
|
|
|
|
var formatHTML = Ember.Handlebars.makeBoundHelper(function (html) {
|
|
|
|
var escapedhtml = html || '';
|
|
|
|
|
|
|
|
// replace script and iFrame
|
|
|
|
escapedhtml = escapedhtml.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
|
2014-07-31 20:42:43 +04:00
|
|
|
'<pre class="js-embed-placeholder">Embedded JavaScript</pre>');
|
2014-07-25 14:42:42 +04:00
|
|
|
escapedhtml = escapedhtml.replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
|
2014-07-31 20:42:43 +04:00
|
|
|
'<pre class="iframe-embed-placeholder">Embedded iFrame</pre>');
|
2014-07-25 14:42:42 +04:00
|
|
|
|
|
|
|
// sanitize HTML
|
|
|
|
escapedhtml = html_sanitize(escapedhtml, cajaSanitizers.url, cajaSanitizers.id);
|
|
|
|
return new Handlebars.SafeString(escapedhtml);
|
|
|
|
});
|
|
|
|
|
|
|
|
export default formatHTML;
|