From d7167e9eeb372127a857fbd87117dd52758f8597 Mon Sep 17 00:00:00 2001 From: thomascube Date: Mon, 28 Feb 2011 09:21:46 +0000 Subject: [PATCH] Workaround for IE not sending referer with location.href (#1487806) --- CHANGELOG | 1 + program/js/app.js | 29 +++++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 60cec4e3f..95c0558bb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ CHANGELOG Roundcube Webmail =========================== +- Force IE to send referers (#1487806) - Fixed de_CH Localization bugs (#1487773) - Better display of vcard import results (#1485457) - Improved vcard import diff --git a/program/js/app.js b/program/js/app.js index b8123e3b1..a155653d0 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -1851,7 +1851,7 @@ function rcube_webmail() if (!this.env.frame_lock) { (this.is_framed() ? parent.rcmail : this).env.frame_lock = this.set_busy(true, 'loading'); } - target.location.href = this.env.comm_path+url; + this.location_href(this.env.comm_path+url, target); // mark as read and change mbox unread counter if (action == 'preview' && this.message_list && this.message_list.rows[id] && this.message_list.rows[id].unread && this.env.preview_pane_mark_read >= 0) { @@ -1973,7 +1973,7 @@ function rcube_webmail() // load message list to target frame/window if (mbox) { this.set_busy(true, 'loading'); - target.location.href = this.env.comm_path+'&_mbox='+urlencode(mbox)+(page ? '&_page='+page : '')+url; + this.location_href(this.env.comm_path+'&_mbox='+urlencode(mbox)+(page ? '&_page='+page : '')+url, target); } }; @@ -3666,7 +3666,7 @@ function rcube_webmail() add_url += '&_search='+this.env.search_request; this.set_busy(true, 'loading'); - target.location.href = this.env.comm_path + (src ? '&_source='+urlencode(src) : '') + add_url; + this.location_href(this.env.comm_path + (src ? '&_source='+urlencode(src) : '') + add_url, target); }; // send remote request to load contacts list @@ -3712,7 +3712,7 @@ function rcube_webmail() add_url += '&_gid='+urlencode(this.env.group); this.set_busy(true); - target.location.href = this.env.comm_path+'&_action='+action+'&_source='+urlencode(this.env.source)+'&_cid='+urlencode(cid) + add_url; + this.location_href(this.env.comm_path+'&_action='+action+'&_source='+urlencode(this.env.source)+'&_cid='+urlencode(cid) + add_url, target); } return true; }; @@ -4187,7 +4187,7 @@ function rcube_webmail() add_url = '&_framed=1'; target = window.frames[this.env.contentframe]; } - target.location.href = this.env.comm_path+'&_action=edit-prefs&_section='+id+add_url; + this.location_href(this.env.comm_path+'&_action=edit-prefs&_section='+id+add_url, target); } return true; @@ -4216,7 +4216,7 @@ function rcube_webmail() if (action && (id || action=='add-identity')) { this.set_busy(true); - target.location.href = this.env.comm_path+'&_action='+action+'&_iid='+id+add_url; + this.location_href(this.env.comm_path+'&_action='+action+'&_iid='+id+add_url, target); } return true; @@ -4481,7 +4481,7 @@ function rcube_webmail() if (!this.env.frame_lock) { (parent.rcmail ? parent.rcmail : this).env.frame_lock = this.set_busy(true, 'loading'); } - target.location.href = this.env.comm_path+url; + this.location_href(this.env.comm_path+url, target); } }; @@ -5185,10 +5185,10 @@ function rcube_webmail() if (lock || lock === null) this.set_busy(true); - if (this.env.framed && window.parent) - parent.location.href = url; + if (this.is_framed()) + parent.redirect(url, lock); else - location.href = url; + this.location_href(url, window); }; this.goto_url = function(action, query, lock) @@ -5196,6 +5196,15 @@ function rcube_webmail() this.redirect(this.url(action, query)); }; + this.location_href = function(url, target) + { + // simulate real link click to force IE to send referer header + if (bw.ie && target == window) + $('').attr('href', url).appendTo(document.body).get(0).click(); + else + target.location.href = url; + }; + // send a http request to the server this.http_request = function(action, query, lock) {