mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 19:02:29 +03:00
18 lines
752 B
JavaScript
18 lines
752 B
JavaScript
/* 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,
|
|
'<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 formatHTML; |