mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 09:52:06 +03:00
2f4f6db133
no issue - add ember-suave dependency - upgrade grunt-jscs dependency - add a new .jscsrc for the client's tests directory that extends from client's base .jscsrc - separate client tests in Gruntfile jscs task so they pick up the test's .jscsrc - standardize es6 usage across client
27 lines
925 B
JavaScript
27 lines
925 B
JavaScript
/* global html_sanitize*/
|
|
import Ember from 'ember';
|
|
import cajaSanitizers from 'ghost/utils/caja-sanitizers';
|
|
|
|
const {Helper} = Ember;
|
|
|
|
export default Helper.helper(function (params) {
|
|
if (!params || !params.length) {
|
|
return;
|
|
}
|
|
|
|
let escapedhtml = params[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);
|
|
});
|