Merge pull request #4217 from natesilva/fix-ipv6-base_url

Build base_url correctly if SERVER_ADDR is IPv6
diff --git a/system/core/Config.php b/system/core/Config.php
index 0264776..c507f34 100644
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -90,7 +90,16 @@
 		{
 			if (isset($_SERVER['SERVER_ADDR']))
 			{
-				$base_url = (is_https() ? 'https' : 'http').'://'.$_SERVER['SERVER_ADDR']
+				if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE)
+				{
+					$server_addr = '['.$_SERVER['SERVER_ADDR'].']';
+				}
+				else
+				{
+					$server_addr = $_SERVER['SERVER_ADDR'];
+				}
+
+				$base_url = (is_https() ? 'https' : 'http').'://'.$server_addr
 					.substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME'])));
 			}
 			else