[FIX] web_editor: prevent editing document in iframe with cross-origin access issue

- Go to Email Marketing
- Create a new mailing with template having social media links
- Save
- Click on one of the social links
An error is triggered:
"Error: Blocked a frame with origin xxx from accessing a cross-origin frame."

The traceback occurs because we try to change the content of something we
don't have access to, as these sites prevent display in an iframe.

opw-2599540

closes odoo/odoo#79208

X-original-commit: 9702e541f27616a5249a140878d028335a0b3775
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
This commit is contained in:
Anh Thao Pham (pta)
2021-10-29 16:05:30 +00:00
parent 1afcc9c368
commit 5e3f143f1c
@@ -325,6 +325,11 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, {
return;
}
var cwindow = self.$iframe[0].contentWindow;
try {
cwindow.document;
} catch (e) {
return;
}
cwindow.document
.open("text/html", "replace")
.write(