From 02642b49d60491d00ec2d0ac522e82faa771f869 Mon Sep 17 00:00:00 2001
From: Jaime Perez <jaime.perez@uninett.no>
Date: Wed, 8 Oct 2014 15:29:48 +0200
Subject: [PATCH] Avoid calling SimpleSAML_Utilities::normalizeURL() twice when
 we are redirecting and need to check if the URL is trusted.

---
 lib/SimpleSAML/Utilities.php | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index e9b9b31e5..abbf9d866 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -652,9 +652,10 @@ class SimpleSAML_Utilities {
 		assert(strlen($url) > 0);
 		assert(is_array($parameters));
 
-		$url = self::normalizeURL($url);
 		if ($allowed_redirect_hosts !== NULL) {
-			$url = self::checkURLAllowed($url, $allowed_redirect_hosts);	
+			$url = self::checkURLAllowed($url, $allowed_redirect_hosts);
+		} else {
+			$url = self::normalizeURL($url);
 		}
 		self::_doRedirect($url, $parameters);
 	}
-- 
GitLab