diff options
| author | IEL <iel@odoo.com> | 2020-10-21 08:52:22 +0000 |
|---|---|---|
| committer | IEL <iel@odoo.com> | 2020-10-21 15:59:35 +0000 |
| commit | 746bf53b4aecfc601f0581a948d7cb7153812c82 (patch) | |
| tree | b99bc7868d7b6b9a46b0f6008dcb6e7adce040f5 /addons/web_editor/static/src | |
| parent | 7d3eb1fc3f0ac86485855bdb433f756fceeaccfb (diff) | |
[FIX] web_editor: disable embedded video for html fields in backend
TLDR: the videos doesn't work anyway, but nobody noticed it for years; at the
same time there is no easy way to fix it
STEPS:
* create a record with html field, e.g. project.task
* add an embedded video (File/Image icon)
* save
BEFORE: video doesn't work
AFTER: there is no option to add embedded video anymore
WHY:
* iframe tags are removed before storing html in database, so after saving a
record, embedded video doesn't work anymore
* possible fixes look too tricky for stable branches:
* new field attribute sanitize_iframe=False -- requires changes in core python framework which may have side effect
* adding iframe on client side -- the problem is that the backend doesn't
have mechanism to use animation in html fields like it's done in
website: https://github.com/odoo/odoo/blob/ced500e9bcbb5c84033463689d135ad4c7dc4f39/addons/website/static/src/js/content/snippets.animation.js#L623-L632
* adding iframe on server side -- parsing html fields in _read... Doesn't look good either
* double selector is required to make it work both in frontend and backend:
$editable.closest('.o_editable, .note-editor')
* we don't need hardcoded exception for mailing.mailing, mail.compose.message
because those fields marked as sanitized (default value)
https://github.com/odoo/odoo/blob/c92f058571b0656451f24e24154dd1bdb3bdb48a/odoo/fields.py#L1589-L1590
https://github.com/odoo/odoo/blob/c92f058571b0656451f24e24154dd1bdb3bdb48a/addons/mail/wizard/mail_compose_message.py#L115
https://github.com/odoo/odoo/blob/61734cdaf1cf6857125b1ece63928ab080359c6c/addons/mass_mailing/models/mailing.py#L77
* I don't apply this for Odoo 12, because js is refactored in Odoo 13 (e.g.
field_html.js has another name in Odoo 12)
---
opw-2353103
closes odoo/odoo#60474
X-original-commit: 2dcbac08effcedafbcf50610355752030902b16d
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Ivan Yelizariev // IEL <yelizariev@users.noreply.github.com>
Diffstat (limited to 'addons/web_editor/static/src')
| -rw-r--r-- | addons/web_editor/static/src/js/backend/field_html.js | 2 | ||||
| -rw-r--r-- | addons/web_editor/static/src/js/editor/rte.summernote.js | 5 |
2 files changed, 3 insertions, 4 deletions
diff --git a/addons/web_editor/static/src/js/backend/field_html.js b/addons/web_editor/static/src/js/backend/field_html.js index 8c7a4eb7264..94b0a469237 100644 --- a/addons/web_editor/static/src/js/backend/field_html.js +++ b/addons/web_editor/static/src/js/backend/field_html.js @@ -225,7 +225,7 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, { toolbar.splice(-1, 0, ['view', ['codeview']]); } } - if ("mailing.mailing" === self.model) { + if (self.field.sanitize && self.field.sanitize_tags) { options.noVideos = true; } options.prettifyHtml = false; diff --git a/addons/web_editor/static/src/js/editor/rte.summernote.js b/addons/web_editor/static/src/js/editor/rte.summernote.js index 96f73267244..7b77404634f 100644 --- a/addons/web_editor/static/src/js/editor/rte.summernote.js +++ b/addons/web_editor/static/src/js/editor/rte.summernote.js @@ -440,14 +440,13 @@ eventHandler.modules.imageDialog.showImageDialog = function ($editable) { var media = $(r.sc).parents().addBack().filter(function (i, el) { return dom.isImg(el); })[0]; + var options = $editable.closest('.o_editable, .note-editor').data('options'); topBus.trigger('media_dialog_demand', { $editable: $editable, media: media, options: { onUpload: $editable.data('callbacks').onUpload, - noVideos: - $editable.data('oe-model') === "mail.compose.message" || - ($editable.data('options') && $editable.data('options').noVideos), + noVideos: options && options.noVideos, }, onSave: function (media) { if(media && !document.body.contains(media)) { |
