From 76eb6e6c748b4ae1b60f2db17b6b4f4c677ab05e Mon Sep 17 00:00:00 2001 From: Benoit Socias Date: Wed, 20 Apr 2022 14:42:38 +0000 Subject: [PATCH] [IMP] web, web_editor: exclude assets from documents Currently only the `*.assets_*` CSS and JS files are considered as assets. Because of this some assets from `web_studio`, `pos` and `document_spreadsheet` become available for selection as documents. This commit replaces the existing blacklist by a check on whether the URL matches `/web/assets/*`. Steps to reproduce: - Install website, web_studio and pos. - Drop a Text - Image block in the home page. - Replace the Image. - Go to the Documents tab. => Some JS/CSS/map assets were available for selection. task-2799866 closes odoo/odoo#89151 Signed-off-by: Romain Derie (rde) --- addons/web/static/src/legacy/js/core/utils.js | 18 ------------------ .../static/src/js/wysiwyg/widgets/media.js | 5 +++-- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/addons/web/static/src/legacy/js/core/utils.js b/addons/web/static/src/legacy/js/core/utils.js index 94e9a25a85b..7e04354e90e 100644 --- a/addons/web/static/src/legacy/js/core/utils.js +++ b/addons/web/static/src/legacy/js/core/utils.js @@ -1129,24 +1129,6 @@ var utils = Object.assign({ } return curr; }, - /** - * Returns the domain targeting assets files. - * - * @returns {Array} Domain of assets files - */ - assetsDomain: function () { - return [ - '&', - ['res_model', '=', 'ir.ui.view'], - '|', - '|', - '|', - ['name', '=like', '%.assets\_%.css'], - ['name', '=like', '%.assets\_%.js'], - ['name', '=like', '%.report_assets\_%.css'], - ['name', '=like', '%.assets\_%.map'], - ]; - }, }, cookieUtils); return utils; diff --git a/addons/web_editor/static/src/js/wysiwyg/widgets/media.js b/addons/web_editor/static/src/js/wysiwyg/widgets/media.js index 76a7ecbb15a..3cac0191254 100644 --- a/addons/web_editor/static/src/js/wysiwyg/widgets/media.js +++ b/addons/web_editor/static/src/js/wysiwyg/widgets/media.js @@ -1069,8 +1069,9 @@ var DocumentWidget = FileWidget.extend({ */ _getAttachmentsDomain: function (needle) { var domain = this._super.apply(this, arguments); - // the assets should not be part of the documents - return domain.concat('!', utils.assetsDomain()); + // The assets should not be part of the documents. + // All assets begin with '/web/assets/', see _get_asset_template_url(). + return ['&', '|', ['url', '=', null], '!', ['url', '=like', '/web/assets/%']].concat(domain); }, });