Skip to content

Commit

Permalink
Handle URI exception
Browse files Browse the repository at this point in the history
  • Loading branch information
rgoers committed Dec 9, 2021
1 parent 4d963a3 commit bac0d8a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Expand Up @@ -252,7 +252,8 @@ public synchronized <T> T lookup(final String name) throws NamingException {
}
}
} catch (URISyntaxException ex) {
// This is OK.
LOGGER.warn("Invalid JNDI URI - {}", name);
return null;
}
return (T) this.context.lookup(name);
}
Expand Down
Expand Up @@ -56,6 +56,19 @@ public static void beforeClass() {
System.setProperty("log4j2.allowedJndiProtocols", "dns");
}

@Test
public void testBadUriLookup() throws Exception {
int port = embeddedLdapRule.embeddedServerPort();
Context context = embeddedLdapRule.context();
context.bind( "cn=" + RESOURCE +"," + DOMAIN_DSN, new Fruit("Test Message"));
final StrLookup lookup = new JndiLookup();
String result = lookup.lookup(LDAP_URL + port + "/" + "cn=" + RESOURCE + "," + DOMAIN_DSN
+ "?Type=A Type&Name=1100110&Char=!");
if (result != null) {
fail("Lookup returned an object");
}
}

@Test
public void testReferenceLookup() throws Exception {
int port = embeddedLdapRule.embeddedServerPort();
Expand Down

0 comments on commit bac0d8a

Please sign in to comment.