From 8847ea31d2bdf9f6594a2969a583f21265c4d724 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaime=20P=C3=A9rez=20Crespo?= <jaime.perez@uninett.no>
Date: Thu, 11 Jul 2013 08:42:23 +0000
Subject: [PATCH] Fix for getServerHost() function incorrectly parsing IPv6
 addresses as hostname.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3254 44740490-163a-0410-bde0-09ae8108e29a
---
 lib/SimpleSAML/Utilities.php | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index e9587ccc5..2a4a9165c 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -59,7 +59,11 @@ class SimpleSAML_Utilities {
 
 		if(strstr($currenthost, ":")) {
 				$currenthostdecomposed = explode(":", $currenthost);
-				$currenthost = $currenthostdecomposed[0];
+				$port = array_pop($currenthostdecomposed);
+				if (!is_numeric($port)) {
+					array_push($currenthostdecomposed, $port);
+                }
+                $currenthost = implode($currenthostdecomposed, ":");
 		}
 		return $currenthost;
 
-- 
GitLab