From 17296b39cbcaeae3352c9656c6081cb72fed9cd1 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Tue, 24 Sep 2019 11:31:17 +0200 Subject: [PATCH] Fix infinite loading message on iframe loading errors The loading message was not stopped on "hard" errors, i.e. when the page was blank, e.g. on 500 error. --- program/js/app.js | 34 +++++++++++++++++++++++---------- program/lib/Roundcube/rcube.php | 3 +++ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/program/js/app.js b/program/js/app.js index 883b885d8..38e4aec7d 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -235,8 +235,7 @@ function rcube_webmail() // tell parent window that this frame is loaded if (this.is_framed()) { - parent.rcmail.set_busy(false, null, parent.rcmail.env.frame_lock); - parent.rcmail.env.frame_lock = null; + parent.rcmail.unlock_frame(); } // enable general commands @@ -2556,11 +2555,10 @@ function rcube_webmail() $(frame)[show ? 'show' : 'hide'](); } - if (!show && this.env.frame_lock) - this.set_busy(false, null, this.env.frame_lock); - - if (!show) + if (!show) { + this.unlock_frame(); delete this.preview_id; + } }; this.get_frame_element = function(id) @@ -2579,10 +2577,26 @@ function rcube_webmail() return window.frames[frame.name]; }; - this.lock_frame = function() + this.lock_frame = function(target) { - if (!this.env.frame_lock) - (this.is_framed() ? parent.rcmail : this).env.frame_lock = this.set_busy(true, 'loading'); + var rc = this.is_framed() ? parent.rcmail : this; + + if (!rc.env.frame_lock) + rc.env.frame_lock = rc.set_busy(true, 'loading'); + + if (target.frameElement) + $(target.frameElement).on('load.lock', function(e) { + rc.unlock_frame(); + $(this).off('load.lock'); + }); + }; + + this.unlock_frame = function() + { + if (this.env.frame_lock) { + this.set_busy(false, null, this.env.frame_lock); + this.env.frame_lock = null; + } }; // list a specific page @@ -8932,7 +8946,7 @@ function rcube_webmail() this.location_href = function(url, target, frame) { if (frame) - this.lock_frame(); + this.lock_frame(target); if (typeof url == 'object') url = this.env.comm_path + '&' + $.param(url); diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php index 2c3b5071e..7e8e6ded1 100644 --- a/program/lib/Roundcube/rcube.php +++ b/program/lib/Roundcube/rcube.php @@ -1348,6 +1348,9 @@ class rcube else if ($terminate && is_object(self::$instance->output)) { self::$instance->output->raise_error($arg['code'], $arg['message']); } + else if ($terminate) { + header("HTTP/1.0 500 Internal Error"); + } // terminate script if ($terminate) {