mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 22:02:11 +03:00
e74e2e039e
no issue - switch `jscs` and `jshint` inline config to `eslint` config - fix eslint errors, predominantly in tests where the config now the main app config more closely
26 lines
887 B
JavaScript
26 lines
887 B
JavaScript
/* global html_sanitize*/
|
|
import {helper} from 'ember-helper';
|
|
import {htmlSafe} from 'ember-string';
|
|
import cajaSanitizers from 'ghost-admin/utils/caja-sanitizers';
|
|
|
|
export default 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
|
|
/* eslint-disable camelcase */
|
|
escapedhtml = html_sanitize(escapedhtml, cajaSanitizers.url, cajaSanitizers.id);
|
|
/* eslint-enable camelcase */
|
|
|
|
return htmlSafe(escapedhtml);
|
|
});
|