[FIX] web_editor: not access cssRules from other domains
domain = host = hostname + port Cause: https://github.com/odoo/odoo/pull/125251 Steps to reproduce: - Add in the custom with a href's host different than the current database host - Open website - Edit it - Click on a block OR add a block and try to save Actual: - Infinite loading due to SecurityError on the cssRules fields Expected: - No infinite loading opw-3432734 opw-3438480 opw-3435892 opw-3371073 closes odoo/odoo#130151 X-original-commit: 8d550d5cc5f055a9de26e3b050550268710b1827 Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
This commit is contained in:
committed by
Benoit Socias
parent
820036049d
commit
2008cff999
@@ -7127,6 +7127,11 @@ registry.BackgroundShape = SnippetOptionWidget.extend({
|
||||
this._lastShapePalette = palette;
|
||||
this._shapeBackgroundImagePerClass = {};
|
||||
for (const styleSheet of this.$target[0].ownerDocument.styleSheets) {
|
||||
if (styleSheet.href && new URL(styleSheet.href).host !== location.host) {
|
||||
// In some browsers, if a stylesheet is loaded from a different domain
|
||||
// accessing cssRules results in a SecurityError.
|
||||
continue;
|
||||
}
|
||||
for (const rule of [...styleSheet.cssRules]) {
|
||||
if (rule.selectorText && rule.selectorText.startsWith(".o_we_shape.")) {
|
||||
this._shapeBackgroundImagePerClass[rule.selectorText] = rule.style.backgroundImage;
|
||||
|
||||
Reference in New Issue
Block a user