From c9e7433c23712f41fa2a93f3ee6464eb94173608 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Thu, 19 Apr 2018 12:55:06 +0200 Subject: [PATCH] [FIX] web_editor: prevent crash on outside-iframe click The editor is performing text selection check when clicking on the window. However, when clicking outside the iframe an editor is running in, a crash may occur as the editor was trying to check a range outside of its environment (the iframe). Related to opw-1837818 --- addons/web_editor/static/src/js/rte.summernote.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/rte.summernote.js b/addons/web_editor/static/src/js/rte.summernote.js index c5a6656ea28..25d966b354d 100644 --- a/addons/web_editor/static/src/js/rte.summernote.js +++ b/addons/web_editor/static/src/js/rte.summernote.js @@ -630,7 +630,15 @@ function summernote_mousedown (event) { } // restore range if range lost after clicking on non-editable area - var r = range.create(); + try { + var r = range.create(); + } catch (e) { + // If this code is running inside an iframe-editor and that the range + // is outside of this iframe, this will fail as the iframe does not have + // the permission to check the outside content this way. In that case, + // we simply ignore the exception as it is as if there was no range. + return; + } var editables = $(".o_editable[contenteditable], .note-editable[contenteditable]"); var r_editable = editables.has((r||{}).sc); if (!r_editable.closest('.note-editor').is($editable) && !r_editable.filter('.o_editable').is(editables)) {