]> granicus.if.org Git - php/commitdiff
Added back support for undocummented host:port syntax
authorCôme Bernigaud <mcmic@php.net>
Mon, 16 Nov 2015 03:50:12 +0000 (04:50 +0100)
committerCôme Bernigaud <mcmic@php.net>
Mon, 16 Nov 2015 03:50:12 +0000 (04:50 +0100)
ext/ldap/ldap.c
ext/ldap/tests/ldap_connect_variation.phpt

index da8936cd763cc891b77134e6ae97d771e7c42e55..8b66ba44ca73bb75a8e8dc1a5b7ab1f8737e2785 100644 (file)
@@ -372,7 +372,12 @@ PHP_FUNCTION(ldap_connect)
                        }
 
                        url = emalloc(urllen);
-                       snprintf( url, urllen, "ldap://%s:%ld", host ? host : "", port );
+                       if (host && (strchr(host, ':') != NULL)) {
+                               /* Legacy support for host:port */
+                               snprintf( url, urllen, "ldap://%s", host );
+                       } else {
+                               snprintf( url, urllen, "ldap://%s:%ld", host ? host : "", port );
+                       }
                }
 
 #ifdef LDAP_API_FEATURE_X_OPENLDAP
index 09b07e778630f0fd5facffd9fb64fdf040f9324a..eaee261542514ef6102113d2d5003df5e92e7e61 100644 (file)
@@ -28,6 +28,10 @@ var_dump($link);
 // bad hostname (connect should work, not bind)
 $link = ldap_connect("nonexistent" . $host);
 var_dump($link);
+
+// Legacy host:port syntax
+$link = ldap_connect("$host:$port");
+var_dump($link);
 ?>
 ===DONE===
 --EXPECTF--
@@ -36,4 +40,5 @@ resource(%d) of type (ldap link)
 resource(%d) of type (ldap link)
 resource(%d) of type (ldap link)
 resource(%d) of type (ldap link)
+resource(%d) of type (ldap link)
 ===DONE===