2014-07-25 05:42:42 -05: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
|
2014-10-24 16:09:50 -05:00
|
|
|
// jscs:disable
|
2014-07-25 05:42:42 -05:00
|
|
|
escapedhtml = escapedhtml.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
|
2014-07-31 11:42:43 -05:00
|
|
|
'<pre class="js-embed-placeholder">Embedded JavaScript</pre>');
|
2014-07-25 05:42:42 -05:00
|
|
|
escapedhtml = escapedhtml.replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
|
2014-07-31 11:42:43 -05:00
|
|
|
'<pre class="iframe-embed-placeholder">Embedded iFrame</pre>');
|
2014-10-24 16:09:50 -05:00
|
|
|
// jscs:enable
|
2014-07-25 05:42:42 -05:00
|
|
|
|
|
|
|
// sanitize HTML
|
2014-10-24 16:09:50 -05:00
|
|
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
2014-07-25 05:42:42 -05:00
|
|
|
escapedhtml = html_sanitize(escapedhtml, cajaSanitizers.url, cajaSanitizers.id);
|
2014-10-24 16:09:50 -05:00
|
|
|
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
|
|
|
|
2014-07-25 05:42:42 -05:00
|
|
|
return new Handlebars.SafeString(escapedhtml);
|
|
|
|
});
|
|
|
|
|
2014-10-24 16:09:50 -05:00
|
|
|
export default formatHTML;
|