git subrepo commit (merge) mailcow/src/mailcow-dockerized

subrepo: subdir:   "mailcow/src/mailcow-dockerized"
  merged:   "02ae5285"
upstream: origin:   "https://github.com/mailcow/mailcow-dockerized.git"
  branch:   "master"
  commit:   "649a5c01"
git-subrepo: version:  "0.4.3"
  origin:   "???"
  commit:   "???"
Change-Id: I870ad468fba026cc5abf3c5699ed1e12ff28b32b
diff --git a/mailcow/src/mailcow-dockerized/data/web/inc/spf.inc.php b/mailcow/src/mailcow-dockerized/data/web/inc/spf.inc.php
index 199f572..55e164b 100644
--- a/mailcow/src/mailcow-dockerized/data/web/inc/spf.inc.php
+++ b/mailcow/src/mailcow-dockerized/data/web/inc/spf.inc.php
@@ -1,8 +1,6 @@
 <?php
 error_reporting(0);
-
-function get_spf_allowed_hosts($check_domain)
-{
+function get_spf_allowed_hosts($check_domain, $expand_ipv6 = false) {
 	$hosts = array();
 	
 	$records = dns_get_record($check_domain, DNS_TXT);
@@ -26,7 +24,7 @@
 				$mod = explode('=', $mech);
 				if ($mod[0] == 'redirect') // handle a redirect
 				{
-					$hosts = get_spf_allowed_hosts($mod[1]);
+					$hosts = get_spf_allowed_hosts($mod[1],true);
 					return $hosts;
 				}
 			}
@@ -81,7 +79,13 @@
 	}
 	foreach ($hosts as &$host) {
 		if (filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
-			$host = $host;
+			if ($expand_ipv6 === true) {
+				$hex = unpack("H*hex", inet_pton($host));
+				$host = substr(preg_replace("/([A-f0-9]{4})/", "$1:", $hex['hex']), 0, -1);
+			}
+			else {
+				$host = $host;
+			}
 		}
 	}
 	return $hosts;
@@ -119,9 +123,8 @@
 		$hosts[] = $a_record['ip'];
 	}
 	$a_records = dns_get_record($domain, DNS_AAAA);
-	foreach ($a_records as $a_record)
-	{
-		$hosts[] = $a_record['ipv6'];
+	foreach ($a_records as $a_record) {
+    $hosts[] = $a_record['ipv6'];
 	}
 	
 	return $hosts;