Fix a bug in NetUtil.createByteArrayFromIpAddressString()
Motivation: An IPv6 string can have a zone index which is followed by the '%' sign. When a user passes an IPv6 string with a zone index, NetUtil.createByteArrayFromIpAddressString() returns an incorrect value. Modification: - Strip the zone index before conversion Result: An IPv6 string with a zone index is decoded correctly.
This commit is contained in:
parent
fe05b6e514
commit
9839990fff
@ -238,6 +238,11 @@ public final class NetUtil {
|
||||
ipAddressString = ipAddressString.substring(1, ipAddressString.length() - 1);
|
||||
}
|
||||
|
||||
int percentPos = ipAddressString.indexOf('%');
|
||||
if (percentPos >= 0) {
|
||||
ipAddressString = ipAddressString.substring(0, percentPos);
|
||||
}
|
||||
|
||||
StringTokenizer tokenizer = new StringTokenizer(ipAddressString, ":.", true);
|
||||
ArrayList<String> hexStrings = new ArrayList<String>();
|
||||
ArrayList<String> decStrings = new ArrayList<String>();
|
||||
|
Loading…
Reference in New Issue
Block a user