This is an automated email from the ASF dual-hosted git repository.
rgoers pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/release-2.x by this push:
new bac0d8a Handle URI exception
bac0d8a is described below
commit bac0d8a35c7e354a0d3f706569116dff6c6bd658
Author: Ralph Goers <[email protected]>
AuthorDate: Thu Dec 9 10:53:21 2021 -0700
Handle URI exception
---
.../java/org/apache/logging/log4j/core/net/JndiManager.java | 3 ++-
.../logging/log4j/core/lookup/JndiRestrictedLookupTest.java | 13 +++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git
a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/JndiManager.java
b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/JndiManager.java
index 2d7604f..b9da6ae 100644
---
a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/JndiManager.java
+++
b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/JndiManager.java
@@ -252,7 +252,8 @@ public class JndiManager extends AbstractManager {
}
}
} catch (URISyntaxException ex) {
- // This is OK.
+ LOGGER.warn("Invalid JNDI URI - {}", name);
+ return null;
}
return (T) this.context.lookup(name);
}
diff --git
a/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/JndiRestrictedLookupTest.java
b/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/JndiRestrictedLookupTest.java
index 032c9c4..c9233a6 100644
---
a/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/JndiRestrictedLookupTest.java
+++
b/log4j-core/src/test/java/org/apache/logging/log4j/core/lookup/JndiRestrictedLookupTest.java
@@ -57,6 +57,19 @@ public class JndiRestrictedLookupTest {
}
@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();
Context context = embeddedLdapRule.context();