EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
iframeSandboxExcludeDomainList
Yuri Kuznetsovc939deb5892a
diff --git a/application/Espo/Resources/defaults/config.php b/application/Espo/Resources/defaults/config.phpindex 0bf1e7bd92..ea84e0bb9f 100644--- a/application/Espo/Resources/defaults/config.php+++ b/application/Espo/Resources/defaults/config.php@@ -318,5 +318,9 @@ return ['emailScheduledBatchCount' => 50,'emailAddressMaxCount' => 10,'phoneNumberMaxCount' => 10,+ 'iframeSandboxExcludeDomainList' => [+ 'youtube.com',+ 'www.google.com',+ ],'isInstalled' => false,];diff --git a/client/src/views/dashlets/iframe.js b/client/src/views/dashlets/iframe.jsindex 232321425a..ccf1152abb 100644--- a/client/src/views/dashlets/iframe.js+++ b/client/src/views/dashlets/iframe.js@@ -32,7 +32,44 @@ class IframeDashletView extends BaseDashletView {name = 'Iframe'- templateContent = '<iframe style="margin: 0; border: 0;" sandbox="allow-scripts"></iframe>'+ /**+ * @private+ * @type {boolean}+ */+ sandboxDisabled = false++ // language=Handlebars+ templateContent = `+ <iframe+ style="margin: 0; border: 0;"+ {{#unless viewObject.sandboxDisabled}}+ sandbox="allow-scripts"+ {{/unless}}+ ></iframe>+ `++ setup() {+ const url = this.getOption('url');++ /** @type {string[]} */+ const excludeDomains = this.getConfig().get('iframeSandboxExcludeDomainList') || [];++ if (url) {+ for (const domain of excludeDomains) {+ try {+ const urlObject = new URL(url);++ if (urlObject.hostname === domain) {+ this.sandboxDisabled = true;++ break;+ }+ } catch (e) {+ console.warn(`Invalid URL ${url}.`);+ }+ }+ }+ }afterRender() {const $iframe = this.$el.find('iframe');