a2bb9d
diff -r 0f7c3698a961 java-sdk/ldapjdk/netscape/ldap/LDAPConnection.java
a2bb9d
--- a/mozilla/directory/java-sdk/ldapjdk/netscape/ldap/LDAPConnection.java	Fri Feb 27 03:58:00 2015 -0500
a2bb9d
+++ b/mozilla/directory/java-sdk/ldapjdk/netscape/ldap/LDAPConnection.java	Mon Aug 08 12:01:38 2016 -0400
a2bb9d
@@ -879,12 +879,14 @@
a2bb9d
      * @param host host name of the LDAP server to which you want to connect.
a2bb9d
      * This value can also be a space-delimited list of hostnames or
a2bb9d
      * hostnames and port numbers (using the syntax
a2bb9d
-     * hostname:portnumber). For example, you can specify
a2bb9d
-     * the following values for the host argument:
a2bb9d
+     * hostname:portnumber). For IPv6 enclose the address in square brackets.
a2bb9d
+     * For example, you can specify the following values for the 
a2bb9d
+     * host argument:
a2bb9d
      *
a2bb9d
      *   myhost
a2bb9d
      *   myhost hishost:389 herhost:5000 whathost
a2bb9d
      *   myhost:686 myhost:389 hishost:5000 whathost:1024
a2bb9d
+     *   [::1]:389 [2620:52:0:102f:5054:1ff:fe2c:e12d]:636
a2bb9d
      *
a2bb9d
      * If multiple servers are specified in the host list, the connection
a2bb9d
      *  setup policy specified with the ConnSetupDelay property controls
a2bb9d
@@ -934,13 +936,32 @@
a2bb9d
         int i = 0;
a2bb9d
         while( st.hasMoreTokens() ) {
a2bb9d
             String s = st.nextToken();
a2bb9d
-            int colon = s.indexOf( ':' );
a2bb9d
-            if ( colon > 0 ) {
a2bb9d
-                hostList[i] = s.substring( 0, colon );
a2bb9d
-                portList[i] = Integer.parseInt( s.substring( colon+1 ) );
a2bb9d
+            int colon;
a2bb9d
+            
a2bb9d
+            if ( s.startsWith( "[" ) ) {
a2bb9d
+                // We have an ipv6 address
a2bb9d
+                int end = s.indexOf( ']' );
a2bb9d
+                if ( end == -1 ) {
a2bb9d
+                    throw new LDAPException ( "invalid URL for IPv6 address",
a2bb9d
+                        LDAPException.PARAM_ERROR );
a2bb9d
+                }
a2bb9d
+                String remainder = s.substring( end+1 );
a2bb9d
+                hostList[i] = s.substring( 0, end+1 );
a2bb9d
+                colon = remainder.indexOf( ':' );
a2bb9d
+                if ( colon >= 0 ){
a2bb9d
+                    portList[i] = Integer.parseInt( remainder.substring( colon+1 ) );
a2bb9d
+                } else {
a2bb9d
+                    portList[i] = defaultPort;
a2bb9d
+                }
a2bb9d
             } else {
a2bb9d
-                hostList[i] = s;
a2bb9d
-                portList[i] = defaultPort;
a2bb9d
+                colon = s.indexOf( ':' );
a2bb9d
+                if ( colon > 0 ) {
a2bb9d
+                    hostList[i] = s.substring( 0, colon );
a2bb9d
+                    portList[i] = Integer.parseInt( s.substring( colon+1 ) );
a2bb9d
+                } else {
a2bb9d
+                    hostList[i] = s;
a2bb9d
+                    portList[i] = defaultPort;
a2bb9d
+                }
a2bb9d
             }
a2bb9d
             i++;
a2bb9d
         }
a2bb9d
diff -r 0f7c3698a961 java-sdk/ldapjdk/netscape/ldap/LDAPUrl.java
a2bb9d
--- a/mozilla/directory/java-sdk/ldapjdk/netscape/ldap/LDAPUrl.java	Fri Feb 27 03:58:00 2015 -0500
a2bb9d
+++ b/mozilla/directory/java-sdk/ldapjdk/netscape/ldap/LDAPUrl.java	Mon Aug 08 12:01:38 2016 -0400
a2bb9d
@@ -135,9 +135,11 @@
a2bb9d
      * (ldaps) is also supported.
a2bb9d
      */
a2bb9d
     private void parseUrl(String url) throws MalformedURLException {
a2bb9d
-        StringTokenizer urlParser = new StringTokenizer (url, ":/?", true);
a2bb9d
+        StringTokenizer urlParser = new StringTokenizer (url, ":/?[]", true);
a2bb9d
+        StringTokenizer markParser = new StringTokenizer (url, ":/?[]", true);
a2bb9d
         String currentToken;
a2bb9d
         String str = null;
a2bb9d
+        boolean usingIPv6 = false;
a2bb9d
 
a2bb9d
         try {
a2bb9d
             currentToken = urlParser.nextToken();
a2bb9d
@@ -160,8 +162,10 @@
a2bb9d
             if (!currentToken.equals("/")) {
a2bb9d
                 throw new MalformedURLException ();
a2bb9d
             }
a2bb9d
-        
a2bb9d
             currentToken = urlParser.nextToken();
a2bb9d
+            if (currentToken.equals("[")) {
a2bb9d
+                usingIPv6 = true;
a2bb9d
+            }
a2bb9d
         }
a2bb9d
         catch (NoSuchElementException e) {
a2bb9d
             throw new MalformedURLException ();
a2bb9d
@@ -176,36 +180,48 @@
a2bb9d
                throw new MalformedURLException ("No hostname");
a2bb9d
         } else if (currentToken.equals ("?")) {
a2bb9d
             throw new MalformedURLException ("No host[:port]");
a2bb9d
+        } else if (usingIPv6){
a2bb9d
+            StringBuilder sb = new StringBuilder();
a2bb9d
+            while (urlParser.hasMoreElements()) {
a2bb9d
+                currentToken = urlParser.nextToken();
a2bb9d
+                if (currentToken.equals("]")) {
a2bb9d
+                    break;
a2bb9d
+                }
a2bb9d
+                sb.append(currentToken);
a2bb9d
+            }
a2bb9d
+            m_hostName = sb.toString();
a2bb9d
         } else {
a2bb9d
             m_hostName = currentToken;
a2bb9d
+        }
a2bb9d
+        
a2bb9d
+        // Set the port
a2bb9d
+        if (urlParser.countTokens() == 0) {
a2bb9d
+            m_portNumber = m_secure ? DEFAULT_SECURE_PORT : LDAPv2.DEFAULT_PORT;
a2bb9d
+            return;
a2bb9d
+        }
a2bb9d
+        currentToken = urlParser.nextToken (); // either ":" or "/"
a2bb9d
+
a2bb9d
+        if (currentToken.equals (":")) {
a2bb9d
+            try {
a2bb9d
+                m_portNumber = Integer.parseInt (urlParser.nextToken());
a2bb9d
+            } catch (NumberFormatException nf) {
a2bb9d
+                throw new MalformedURLException ("Port not a number");
a2bb9d
+            } catch (NoSuchElementException ex) {
a2bb9d
+                throw new MalformedURLException ("No port number");
a2bb9d
+            }
a2bb9d
+                
a2bb9d
             if (urlParser.countTokens() == 0) {
a2bb9d
-                m_portNumber = m_secure ? DEFAULT_SECURE_PORT : LDAPv2.DEFAULT_PORT;
a2bb9d
                 return;
a2bb9d
             }
a2bb9d
-            currentToken = urlParser.nextToken (); // either ":" or "/"
a2bb9d
-
a2bb9d
-            if (currentToken.equals (":")) {
a2bb9d
-                try {
a2bb9d
-                    m_portNumber = Integer.parseInt (urlParser.nextToken());
a2bb9d
-                } catch (NumberFormatException nf) {
a2bb9d
-                    throw new MalformedURLException ("Port not a number");
a2bb9d
-                } catch (NoSuchElementException ex) {
a2bb9d
-                    throw new MalformedURLException ("No port number");
a2bb9d
-                }
a2bb9d
-                    
a2bb9d
-                if (urlParser.countTokens() == 0) {
a2bb9d
-                    return;
a2bb9d
-                }
a2bb9d
-                else if (! urlParser.nextToken().equals("/")) {
a2bb9d
-                   throw new MalformedURLException ();
a2bb9d
-                }
a2bb9d
-
a2bb9d
-            } else if (currentToken.equals ("/")) {
a2bb9d
-                m_portNumber = m_secure ? DEFAULT_SECURE_PORT : LDAPv2.DEFAULT_PORT;
a2bb9d
-            } else {
a2bb9d
-                // expecting ":" or "/"
a2bb9d
+            else if (! urlParser.nextToken().equals("/")) {
a2bb9d
                 throw new MalformedURLException ();
a2bb9d
             }
a2bb9d
+
a2bb9d
+        } else if (currentToken.equals ("/")) {
a2bb9d
+            m_portNumber = m_secure ? DEFAULT_SECURE_PORT : LDAPv2.DEFAULT_PORT;
a2bb9d
+        } else {
a2bb9d
+            // expecting ":" or "/"
a2bb9d
+            throw new MalformedURLException ();
a2bb9d
         }