From a8f8ded1ce463a0cd21d62906b74a86e83fbf6bb Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Mon, 18 Dec 2023 19:31:52 +0100 Subject: [PATCH] [FIX] website: prevent img url to become absolute with animation option Using the animation option on an image can turn the image src from relative to absolute. It then makes our code crash in some cases (multi domain & cors protected img). The previous commit makes sure to protect this case by making the code more robust. This commit is fixing one of the detected root cause (explained in previous commit). The fixed code was introduced with commit [1]. Since we can't guarantee our code has no other way to turn relative into absolute url, neither that we won't introduce new code doing that, the very small safety net from previous commit has to be keep as defensive programming. [1]: https://github.com/odoo/odoo/commit/7f730f81ec541cc7791fc6b3fded17c838433f85 closes odoo/odoo#146731 Signed-off-by: Quentin Smetz (qsm) --- .../website/static/src/js/content/snippets.animation.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/website/static/src/js/content/snippets.animation.js b/addons/website/static/src/js/content/snippets.animation.js index 1854ac4332e..9c0844e44f5 100644 --- a/addons/website/static/src/js/content/snippets.animation.js +++ b/addons/website/static/src/js/content/snippets.animation.js @@ -1702,14 +1702,14 @@ registry.ImageShapeHoverEffet = publicWidget.Widget.extend({ */ start() { this._super(...arguments); - this.originalImgSrc = this.el.src; + this.originalImgSrc = this.el.getAttribute('src'); }, /** * @override */ destroy() { this._super(...arguments); - if (this.originalImgSrc && (this.lastImgSrc === this.el.src)) { + if (this.originalImgSrc && (this.lastImgSrc === this.el.getAttribute('src'))) { this.el.src = this.originalImgSrc; } }, @@ -1808,9 +1808,9 @@ registry.ImageShapeHoverEffet = publicWidget.Widget.extend({ return; } this.options.wysiwyg && this.options.wysiwyg.odooEditor.observerUnactive("setImgHoverEffectSrc"); - this.el.src = preloadedImg.src; + this.el.src = preloadedImg.getAttribute('src'); this.options.wysiwyg && this.options.wysiwyg.odooEditor.observerActive("setImgHoverEffectSrc"); - this.lastImgSrc = preloadedImg.src; + this.lastImgSrc = preloadedImg.getAttribute('src'); this.el.onload = () => { resolve(); };