diff --git a/application/Espo/Resources/metadata/entityDefs/EmailTemplate.json b/application/Espo/Resources/metadata/entityDefs/EmailTemplate.json index 456494ce94..a96593eb4c 100644 --- a/application/Espo/Resources/metadata/entityDefs/EmailTemplate.json +++ b/application/Espo/Resources/metadata/entityDefs/EmailTemplate.json @@ -10,7 +10,7 @@ }, "body": { "type": "wysiwyg", - "view": "views/fields/wysiwyg", + "view": "views/email-template/fields/body", "useIframe": true }, "isHtml": { diff --git a/application/Espo/Resources/metadata/entityDefs/Template.json b/application/Espo/Resources/metadata/entityDefs/Template.json index 0e49d4db23..498d0c2206 100644 --- a/application/Espo/Resources/metadata/entityDefs/Template.json +++ b/application/Espo/Resources/metadata/entityDefs/Template.json @@ -7,15 +7,15 @@ }, "body": { "type": "wysiwyg", - "view": "views/fields/wysiwyg" + "view": "views/template/fields/body" }, "header": { "type": "wysiwyg", - "view": "views/fields/wysiwyg" + "view": "views/template/fields/body" }, "footer": { "type": "wysiwyg", - "view": "views/fields/wysiwyg", + "view": "views/template/fields/body", "tooltip": true }, "entityType": { diff --git a/client/modules/crm/src/views/knowledge-base-article/record/detail.js b/client/modules/crm/src/views/knowledge-base-article/record/detail.js index d84e635653..5825d635e8 100644 --- a/client/modules/crm/src/views/knowledge-base-article/record/detail.js +++ b/client/modules/crm/src/views/knowledge-base-article/record/detail.js @@ -77,6 +77,12 @@ Espo.define('crm:views/knowledge-base-article/record/detail', 'views/record/deta }, this); }, + afterRender: function () { + Dep.prototype.afterRender.call(this); + if (this.getUser().isPortal()) { + this.$el.find('.field[data-name="body"]').css('minHeight', '400px'); + } + }, + }); }); - diff --git a/client/src/collection.js b/client/src/collection.js index b82c5e44fc..4c568ff816 100644 --- a/client/src/collection.js +++ b/client/src/collection.js @@ -178,7 +178,11 @@ define('collection', [], function () { }, getWhere: function () { - return (this.where || []).concat(this.whereAdditional || []); + var where = (this.where || []).concat(this.whereAdditional || []); + if (this.whereFunction) { + where = where.concat(this.whereFunction() || []); + } + return where; }, getUser: function () { diff --git a/client/src/view-helper.js b/client/src/view-helper.js index ff93dc4817..be2724fb64 100644 --- a/client/src/view-helper.js +++ b/client/src/view-helper.js @@ -318,8 +318,8 @@ define('view-helper', ['lib!client/lib/purify.min.js'], function () { return html; }, - sanitizeHtml: function (text) { - return DOMPurify.sanitize(text); + sanitizeHtml: function (text, options) { + return DOMPurify.sanitize(text, options); }, }); diff --git a/client/src/views/email-template/fields/body.js b/client/src/views/email-template/fields/body.js new file mode 100644 index 0000000000..809c9f0395 --- /dev/null +++ b/client/src/views/email-template/fields/body.js @@ -0,0 +1,34 @@ +/************************************************************************ + * This file is part of EspoCRM. + * + * EspoCRM - Open Source CRM application. + * Copyright (C) 2014-2019 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko + * Website: https://www.espocrm.com + * + * EspoCRM is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * EspoCRM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with EspoCRM. If not, see http://www.gnu.org/licenses/. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU General Public License version 3. + * + * In accordance with Section 7(b) of the GNU General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. + ************************************************************************/ + +define('views/email-template/fields/body', 'views/fields/wysiwyg', function (Dep) { + + return Dep.extend({ + + }); +}); diff --git a/client/src/views/fields/wysiwyg.js b/client/src/views/fields/wysiwyg.js index ab2718e9d9..a7b2c02d4d 100644 --- a/client/src/views/fields/wysiwyg.js +++ b/client/src/views/fields/wysiwyg.js @@ -154,19 +154,46 @@ Espo.define('views/fields/wysiwyg', ['views/fields/text', 'lib!Summernote'], fun sanitizeHtml: function (value) { if (value) { - value = value.replace(/<[\/]{0,1}(base)[^><]*>/gi, ''); - value = value.replace(/<[\/]{0,1}(script)[^><]*>/gi, ''); - value = value.replace(/<[^><]*([^a-z]{1}on[a-z]+)=[^><]*>/gi, function (match) { - return match.replace(/[^a-z]{1}on[a-z]+=/gi, ' data-handler-stripped='); - }); - value = this.getHelper().sanitizeHtml(value); + if (!this.htmlPurificationDisabled) { + value = this.getHelper().sanitizeHtml(value); + } else { + value = this.sanitizeHtmlLight(value); + } } return value || ''; }, + + sanitizeHtmlLight: function (value) { + value = value || ''; + value = value.replace(/<[\/]{0,1}(base)[^><]*>/gi, ''); + value = value.replace(/<[\/]{0,1}(object)[^><]*>/gi, ''); + value = value.replace(/<[\/]{0,1}(embed)[^><]*>/gi, ''); + value = value.replace(/<[\/]{0,1}(applet)[^><]*>/gi, ''); + value = value.replace(/<[\/]{0,1}(iframe)[^><]*>/gi, ''); + value = value.replace(/<[\/]{0,1}(script)[^><]*>/gi, ''); + value = value.replace(/<[^><]*([^a-z]{1}on[a-z]+)=[^><]*>/gi, function (match) { + return match.replace(/[^a-z]{1}on[a-z]+=/gi, ' data-handler-stripped='); + }); + + value = value.replace(/href=" *javascript\:(.*?)"/gi, function(m, $1) { + return 'removed=""'; + }); + value = value.replace(/href=' *javascript\:(.*?)'/gi, function(m, $1) { + return 'removed=""'; + }); + value = value.replace(/src=" *javascript\:(.*?)"/gi, function(m, $1) { + return 'removed=""'; + }); + value = value.replace(/src=' *javascript\:(.*?)'/gi, function(m, $1) { + return 'removed=""'; + }); + return value; + }, + getValueForEdit: function () { var value = this.model.get(this.name) || ''; - return this.sanitizeHtml(value); + return this.sanitizeHtmlLight(value); }, afterRender: function () { diff --git a/client/src/views/list-with-categories.js b/client/src/views/list-with-categories.js index 20125417fb..46d8bb7f36 100644 --- a/client/src/views/list-with-categories.js +++ b/client/src/views/list-with-categories.js @@ -87,6 +87,7 @@ Espo.define('views/list-with-categories', 'views/list', function (Dep) { } } else { this.hasExpandedToggler = false; + this.isExpanded = false; } } } @@ -128,7 +129,8 @@ Espo.define('views/list-with-categories', 'views/list', function (Dep) { }, getIsExpandedStoredValue: function () { - return this.getStorage().get('state', 'categories-expanded-' + this.scope) === 'true'; + var value = this.getStorage().get('state', 'categories-expanded-' + this.scope); + return value === 'true' || value === true ; }, setIsExpandedStoredValue: function (value) { @@ -395,49 +397,67 @@ Espo.define('views/list-with-categories', 'views/list', function (Dep) { }, applyCategoryToCollection: function () { - this.collection.whereAdditional = null; - var filter; - if (!this.isExpanded) { - if (this.isCategoryMultiple()) { - if (this.currentCategoryId) { - filter = { - attribute: this.categoryField, - type: 'linkedWith', - value: [this.currentCategoryId] - }; + + this.collection.whereFunction = function () { + var filter; + var isExpanded = this.isExpanded; + + var hasTextFilter = false; + if (this.collection.where) { + for (var i = 0; i < this.collection.where.length; i++) { + if (this.collection.where[i].type === 'textFilter') { + hasTextFilter = true; + break; + } + } + } + + if (this.collection.data && this.collection.data.textFilter) { + hasTextFilter = true; + } + + if (!isExpanded && !hasTextFilter) { + if (this.isCategoryMultiple()) { + if (this.currentCategoryId) { + filter = { + attribute: this.categoryField, + type: 'linkedWith', + value: [this.currentCategoryId] + }; + } else { + filter = { + attribute: this.categoryField, + type: 'isNotLinked' + }; + } } else { - filter = { - attribute: this.categoryField, - type: 'isNotLinked' - }; + if (this.currentCategoryId) { + filter = { + attribute: this.categoryField + 'Id', + type: 'equals', + value: this.currentCategoryId + }; + } else { + filter = { + attribute: this.categoryField + 'Id', + type: 'isNull' + }; + } } } else { if (this.currentCategoryId) { filter = { - attribute: this.categoryField + 'Id', - type: 'equals', + field: this.categoryField, + type: this.categoryFilterType, value: this.currentCategoryId }; - } else { - filter = { - attribute: this.categoryField + 'Id', - type: 'isNull' - }; } } - } else { - if (this.currentCategoryId) { - filter = { - field: this.categoryField, - type: this.categoryFilterType, - value: this.currentCategoryId - }; + if (filter) { + return [filter]; } - } - if (filter) { - this.collection.whereAdditional = [filter]; - } + }.bind(this); }, isCategoryMultiple: function () { diff --git a/client/src/views/site-portal/master.js b/client/src/views/site-portal/master.js index 0c685f4d0c..05181f2b9a 100644 --- a/client/src/views/site-portal/master.js +++ b/client/src/views/site-portal/master.js @@ -26,7 +26,7 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('views/site-portal/master', 'views/site/master', function (Dep) { +define('views/site-portal/master', 'views/site/master', function (Dep) { return Dep.extend({ @@ -45,9 +45,12 @@ Espo.define('views/site-portal/master', 'views/site/master', function (Dep) { el: 'body > footer', view: 'views/site/footer' } - } + }, + + afterRender: function () { + Dep.prototype.afterRender.call(this); + this.$el.find('#main').addClass('main-portal'); + }, }); }); - - diff --git a/client/src/views/template/fields/body.js b/client/src/views/template/fields/body.js new file mode 100644 index 0000000000..a0ab44e1aa --- /dev/null +++ b/client/src/views/template/fields/body.js @@ -0,0 +1,34 @@ +/************************************************************************ + * This file is part of EspoCRM. + * + * EspoCRM - Open Source CRM application. + * Copyright (C) 2014-2019 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko + * Website: https://www.espocrm.com + * + * EspoCRM is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * EspoCRM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with EspoCRM. If not, see http://www.gnu.org/licenses/. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU General Public License version 3. + * + * In accordance with Section 7(b) of the GNU General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. + ************************************************************************/ + +define('views/template/fields/body', 'views/fields/wysiwyg', function (Dep) { + + return Dep.extend({ + + }); +}); diff --git a/package.json b/package.json index 6200df0f31..2b5988c98e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "espocrm", - "version": "5.6.7", + "version": "5.6.8", "description": "", "main": "index.php", "repository": {