[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: `<iframe style="display: none;"></iframe>` 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) <rde@odoo.com>
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user