From 81f019b6c5aea827b72dc2aef115e4f0a5cf48c1 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Wed, 31 Oct 2012 22:03:55 +0100 Subject: Make the redirect_url working again Fixes #160 --- core/templates/login.php | 2 +- lib/base.php | 2 +- lib/util.php | 10 ++++------ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/core/templates/login.php b/core/templates/login.php index 0768b664c6f..e8db883c9d0 100644 --- a/core/templates/login.php +++ b/core/templates/login.php @@ -1,7 +1,7 @@
- '; } ?> + '; } ?>
  • diff --git a/lib/base.php b/lib/base.php index 5c3d3fb80ce..eee36da2eb2 100644 --- a/lib/base.php +++ b/lib/base.php @@ -656,7 +656,7 @@ class OC{ else { OC_User::unsetMagicInCookie(); } - header( 'Location: '.$_SERVER['REQUEST_URI'] ); + OC_Util::redirectToDefaultPage(); exit(); } return true; diff --git a/lib/util.php b/lib/util.php index de89e339d99..622a42982c3 100755 --- a/lib/util.php +++ b/lib/util.php @@ -340,10 +340,8 @@ class OC_Util { } if (isset($_REQUEST['redirect_url'])) { $redirect_url = OC_Util::sanitizeHTML($_REQUEST['redirect_url']); - } else { - $redirect_url = $_SERVER['REQUEST_URI']; - } - $parameters['redirect_url'] = $redirect_url; + } + $parameters['redirect_url'] = urlencode($redirect_url); OC_Template::printGuestPage("", "login", $parameters); } @@ -439,8 +437,8 @@ class OC_Util { * Redirect to the user default page */ public static function redirectToDefaultPage() { - if(isset($_REQUEST['redirect_url']) && (substr($_REQUEST['redirect_url'], 0, strlen(OC::$WEBROOT)) == OC::$WEBROOT || $_REQUEST['redirect_url'][0] == '/')) { - $location = $_REQUEST['redirect_url']; + if(isset($_REQUEST['redirect_url'])) { + $location = OC_Helper::makeURLAbsolute(urldecode($_REQUEST['redirect_url'])); } else if (isset(OC::$REQUESTEDAPP) && !empty(OC::$REQUESTEDAPP)) { $location = OC_Helper::linkToAbsolute( OC::$REQUESTEDAPP, 'index.php' ); -- cgit v1.2.3 From 822e4d5f6c21c24ec9f39f271106d9fc2c28c6b6 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Thu, 1 Nov 2012 22:37:37 +0100 Subject: Check for redirect_url for logged in users This checks if there is a redirect_url for logged in users --- lib/base.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/base.php b/lib/base.php index eee36da2eb2..0d3de2c3642 100644 --- a/lib/base.php +++ b/lib/base.php @@ -490,6 +490,13 @@ class OC{ require_once 'setup.php'; exit(); } + // Handle redirect URL for logged in users + if(isset($_REQUEST['redirect_url']) && OC_User::isLoggedIn()) { + $location = OC_Helper::makeURLAbsolute(urldecode($_REQUEST['redirect_url'])); + header( 'Location: '.$location ); + return; + } + // Handle WebDAV if($_SERVER['REQUEST_METHOD']=='PROPFIND') { header('location: '.OC_Helper::linkToRemote('webdav')); -- cgit v1.2.3 From d2e842fcc99b39f0acf9500dd96f6d55e30b5bc0 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Thu, 1 Nov 2012 22:38:21 +0100 Subject: Remove uneeded new line --- lib/base.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/base.php b/lib/base.php index 0d3de2c3642..07743a5c99e 100644 --- a/lib/base.php +++ b/lib/base.php @@ -496,7 +496,6 @@ class OC{ header( 'Location: '.$location ); return; } - // Handle WebDAV if($_SERVER['REQUEST_METHOD']=='PROPFIND') { header('location: '.OC_Helper::linkToRemote('webdav')); -- cgit v1.2.3 From 271b8384e7adc36b7c1a3df813c6a6156c661a0d Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 7 Dec 2012 12:07:56 +0100 Subject: Fix warning about redirect_url not set --- lib/util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util.php b/lib/util.php index 622a42982c3..c4ed1f6ba7c 100755 --- a/lib/util.php +++ b/lib/util.php @@ -340,8 +340,8 @@ class OC_Util { } if (isset($_REQUEST['redirect_url'])) { $redirect_url = OC_Util::sanitizeHTML($_REQUEST['redirect_url']); + $parameters['redirect_url'] = urlencode($redirect_url); } - $parameters['redirect_url'] = urlencode($redirect_url); OC_Template::printGuestPage("", "login", $parameters); } -- cgit v1.2.3