From 051442bc7654cc41bc8e1bb48762494764111daa Mon Sep 17 00:00:00 2001
From: Michael Gapczynski <GapczynskiM@gmail.com>
Date: Tue, 8 May 2012 17:41:50 -0400
Subject: [PATCH] Sanitize redirect urls

---
 index.php    | 2 +-
 lib/util.php | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/index.php b/index.php
index 5d5307065bd..952cd89141a 100644
--- a/index.php
+++ b/index.php
@@ -115,6 +115,6 @@ elseif(OC_User::isLoggedIn()) {
 	if(is_null(OC::$REQUESTEDFILE)){
 		$sectoken=rand(1000000,9999999);
 		$_SESSION['sectoken']=$sectoken;
-		OC_Template::printGuestPage('', 'login', array('error' => $error, 'sectoken' => $sectoken, 'redirect' => isset($_REQUEST['redirect_url'])?strip_tags($_REQUEST['redirect_url']):'' ));
+		OC_Template::printGuestPage('', 'login', array('error' => $error, 'sectoken' => $sectoken, 'redirect' => isset($_REQUEST['redirect_url'])?htmlentities($_REQUEST['redirect_url']):'' ));
 	}
 }
diff --git a/lib/util.php b/lib/util.php
index 8cf6b3c0307..e4546d6ac3d 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -312,7 +312,7 @@ class OC_Util {
 	*/
 	public static function redirectToDefaultPage(){
 		if(isset($_REQUEST['redirect_url'])) {
-			header( 'Location: '.$_REQUEST['redirect_url']);
+			header( 'Location: '.htmlentities($_REQUEST['redirect_url']));
 		} else {
 			header( 'Location: '.OC::$WEBROOT.'/'.OC_Appconfig::getValue('core', 'defaultpage', '?app=files'));
 		}
-- 
GitLab