From f63dec4bb2a6148ae0ea56e98af970aa2ed67505 Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Thu, 18 Dec 2014 16:32:52 +0800 Subject: [PATCH] MDL-43679 core: Never use HTTP redirect when the user agent is MS Word --- lib/weblib.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/weblib.php b/lib/weblib.php index c843fa2e2b3..8fb28a643a0 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -2551,6 +2551,16 @@ function redirect($url, $message='', $delay=-1) { break; } + if (core_useragent::is_msword()) { + // Clicking a URL from MS Word sends a request to the server without cookies. If that + // causes a redirect Word will open a browser pointing the new URL. If not, the URL that + // was clicked is opened. Because the request from Word is without cookies, it almost + // always results in a redirect to the login page, even if the user is logged in in their + // browser. This is not what we want, so prevent the redirect for requests from Word. + $debugdisableredirect = true; + break; + } + if (empty($CFG->debugdisplay) or empty($CFG->debug)) { // No errors should be displayed. break;