From 755ab306190be4d1bfb11d8b9fd5e7cf4cc34b3f Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Fri, 2 Jun 2023 16:03:31 +0000 Subject: [PATCH] [FIX] website: prevent traceback when iframe has no src Commit [1] introduced an cleaning of the iframefallback on page unload, which was removing the `autoplay` attribute of the iframe `src` URL. It was done to prevent video/music to keep playing in the invisible iframe. The fix was not generic and purposely targetted the elements which we identified as problematic. Commit [2] then made that cleaning generic, catching all iframe. Doing so, it was actually catching too many iframes and led to traceback on iframe not having a set `src`. This is the case for every database having a configured reCaptcha, among other things. For reCaptcha, it's because it's adding the following iframe dynamically through their third party script: `` This commit ensures we only target iframe having an URL attribute being set to something. Step to reproduce (with reCaptcha): - Enable and configure reCaptcha - Go to /contactus - Leave the iframe page, eg click on "Contactus" menu to refresh it -> Traceback [1]: https://github.com/odoo/odoo/commit/ad78585cd514f5ff16647572d34937c18a112529 [2]: https://github.com/odoo/odoo/commit/6be8af36726d750065972e122e8f4a0aa0f56a17 opw-3343450 closes odoo/odoo#123621 X-original-commit: 463d4ee0c8000f948463772b7c96c8d111bcbc8e Signed-off-by: Romain Derie (rde) --- .../src/client_actions/website_preview/website_preview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website/static/src/client_actions/website_preview/website_preview.js b/addons/website/static/src/client_actions/website_preview/website_preview.js index 8cc97a1e026..06a8ea21c60 100644 --- a/addons/website/static/src/client_actions/website_preview/website_preview.js +++ b/addons/website/static/src/client_actions/website_preview/website_preview.js @@ -428,7 +428,7 @@ export class WebsitePreview extends Component { _cleanIframeFallback() { // Remove autoplay in all iframes urls so videos are not // playing in the background - const iframesEl = this.iframefallback.el.contentDocument.querySelectorAll("iframe"); + const iframesEl = this.iframefallback.el.contentDocument.querySelectorAll('iframe[src]:not([src=""])'); for (const iframeEl of iframesEl) { const url = new URL(iframeEl.src); url.searchParams.delete('autoplay');