mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-07 11:30:55 +03:00
2a91a1071e
No issue. - Ember@1.10.0 - Update grunt-ember-templates to version that supports HTMLBars. - Update Gruntfile.js to compile templates with HTMLBars. - Convert Handlebars code to its HTMLBars equivalent.
26 lines
925 B
JavaScript
26 lines
925 B
JavaScript
/* global html_sanitize*/
|
|
import cajaSanitizers from 'ghost/utils/caja-sanitizers';
|
|
|
|
var formatHTML = Ember.HTMLBars.makeBoundHelper(function (arr /* hashParams */) {
|
|
if (!arr || !arr.length) {
|
|
return;
|
|
}
|
|
|
|
var escapedhtml = arr[0] || '';
|
|
|
|
// 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 Ember.String.htmlSafe(escapedhtml);
|
|
});
|
|
|
|
export default formatHTML;
|