Skip to content

Commit cb32c69

Browse files
committed
Patch for DIRAPI-402
1 parent 3934304 commit cb32c69

File tree

2 files changed

+16
-1
lines changed
  • ldap/model/src

2 files changed

+16
-1
lines changed

ldap/model/src/main/java/org/apache/directory/api/ldap/model/url/LdapUrl.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,14 @@ private void parse( char[] chars ) throws LdapURLEncodingException
223223
}
224224
scheme = new String( chars, 0, pos );
225225

226-
// The hostport
226+
// The hostport, if it exists
227+
if ( pos == chars.length )
228+
{
229+
return;
230+
}
231+
227232
pos = parseHostPort( chars, pos );
233+
228234
if ( pos == -1 )
229235
{
230236
throw new LdapURLEncodingException( I18n.err( I18n.ERR_13031_INVALID_HOST_PORT ) );

ldap/model/src/test/java/org/apache/directory/api/ldap/model/url/LdapUrlTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,4 +1690,13 @@ public void hangingLdapUrl()
16901690
{
16911691
assertThrows( LdapURLEncodingException.class, () -> new LdapUrl( "ldap://[1:2:ldap:///o" ) );
16921692
}
1693+
1694+
1695+
@Test
1696+
public void indexOutOfRangeLdapUrl() throws LdapURLEncodingException
1697+
{
1698+
LdapUrl ldapUrl = new LdapUrl( "ldap://" );
1699+
1700+
assertNull( ldapUrl.getHost() );
1701+
}
16931702
}

0 commit comments

Comments
 (0)