mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-05 18:34:39 +03:00
1c07273f5a
No Issue - grunt-jscs@1.2.0 - Clean up some instances of multiple spaces. - Remove jscs:disable for regexes now that jscs better supports them.
22 lines
871 B
JavaScript
22 lines
871 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
|
|
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
|
|
escapedhtml = html_sanitize(escapedhtml, cajaSanitizers.url, cajaSanitizers.id);
|
|
// jscs:enable requireCamelCaseOrUpperCaseIdentifiers
|
|
|
|
return new Handlebars.SafeString(escapedhtml);
|
|
});
|
|
|
|
export default formatHTML;
|