Skip to content

Commit f20eb28

Browse files
committed
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 f2582e9 commit f20eb28

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

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) {

src/test/java/io/vertx/core/net/impl/HostAndPortTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ public void testParseInvalid() {
8888
assertFalse(HostAndPortImpl.isValidAuthority("http://localhost:8080"));
8989
assertNull(HostAndPortImpl.parseAuthority("^", -1));
9090
assertFalse(HostAndPortImpl.isValidAuthority("^"));
91+
assertNull(HostAndPortImpl.parseAuthority("bücher.de", -1));
92+
assertFalse(HostAndPortImpl.isValidAuthority("bücher.de"));
9193
}
9294

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

0 commit comments

Comments
 (0)