[FIX] web_editor: prevent crash if data-shape-colors is not set
There is cases leading to have a `data-shape` but no
`data-shape-colors`. It then makes the code crash.
Step to reproduce:
- Drag & drop "Text - Image" snippet
- Double click on an image to replace it
- Select in the media dialog "Add URL" and insert a CORS protected
image URL
- The image is correctly added, and its url is something like
`/web/image/123-redirect/xxx.jpg`
- Click on the image and then click on its "Animation" option
-> It crashes
In such a case, the code was crashing on the line below this fix:
`img.dataset.shapeColors.split(';')`
The modified code here is related to commit [1].
But the code only break in Odoo 17, probably following commit [2].
[1]: https://github.com/odoo/odoo/commit/cd403480f90cf7103651f3be818a14b06d3c73ca
[2]: https://github.com/odoo/odoo/commit/7f730f81ec541cc7791fc6b3fded17c838433f85
Part-of: odoo/odoo#146732
This commit is contained in:
@@ -7002,7 +7002,8 @@ registry.ImageTools = ImageHandlerOption.extend({
|
||||
if (widgetName.startsWith('img-shape-color')) {
|
||||
const img = this._getImg();
|
||||
const shapeName = img.dataset.shape;
|
||||
if (!shapeName) {
|
||||
const shapeColors = img.dataset.shapeColors;
|
||||
if (!shapeName || !shapeColors) {
|
||||
return false;
|
||||
}
|
||||
const colors = img.dataset.shapeColors.split(';');
|
||||
|
||||
Reference in New Issue
Block a user