[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) <qsm@odoo.com>
This commit is contained in:
Romain Derie
2023-12-21 16:07:46 +00:00
parent c51dc918fd
commit a8f8ded1ce
@@ -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();
};