Skip to content

Commit 4eca1c7

Browse files
authored
HostAndPortImpl#isDIGIT throws ArrayOtOfboundException (#5752)
See #5691 Happens when non-ascii characters are used in domain names Signed-off-by: Thomas Segismont <[email protected]>
1 parent dcf2483 commit 4eca1c7

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

vertx-core/src/main/java/io/vertx/core/net/impl/HostAndPortImpl.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package io.vertx.core.net.impl;
22

3-
import java.util.Arrays;
4-
53
import io.vertx.core.net.HostAndPort;
64

5+
import java.util.Arrays;
6+
77
public class HostAndPortImpl implements HostAndPort {
88

99
// digits lookup table to speed-up parsing
@@ -126,7 +126,10 @@ private static boolean isALPHA(char ch) {
126126
}
127127

128128
private static boolean isDIGIT(char ch) {
129-
return DIGITS[ch] != -1;
129+
if (ch < 128) {
130+
return DIGITS[ch] != -1;
131+
}
132+
return false;
130133
}
131134

132135
private static boolean isSubDelims(char ch) {

vertx-core/src/test/java/io/vertx/tests/net/HostAndPortTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ public void testParseInvalid() {
9292
assertFalse(HostAndPortImpl.isValidAuthority("http://localhost:8080"));
9393
assertNull(HostAndPortImpl.parseAuthority("^", -1));
9494
assertFalse(HostAndPortImpl.isValidAuthority("^"));
95+
assertNull(HostAndPortImpl.parseAuthority("bücher.de", -1));
96+
assertFalse(HostAndPortImpl.isValidAuthority("bücher.de"));
9597
}
9698

9799
private void assertHostAndPort(String expectedHost, int expectedPort, String actual) {

0 commit comments

Comments
 (0)