From 81f019b6c5aea827b72dc2aef115e4f0a5cf48c1 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Wed, 31 Oct 2012 22:03:55 +0100 Subject: [PATCH] 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 0768b664c6..e8db883c9d 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 5c3d3fb80c..eee36da2eb 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 de89e339d9..622a42982c 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' );