FULL PRODUCT VERSION :
java version "1.6.0_15"
Java(TM) SE Runtime Environment (build 1.6.0_15-b03)
Java HotSpot(TM) 64-Bit Server VM (build 14.1-b02, mixed mode)
A DESCRIPTION OF THE PROBLEM :
The .toASCII and .toUnicode methods of java.net.IDN always return a hostname without a trailing dot, even when the input string did have a trailing dot. Because hostnames with and without a trailing dots are not semantically the same, I think a trailing dot should be preserved.
In both methods the following check is used to determine whether a dot should be added or not:
if (p < input.length()) out.append('.');
By changing this into
if (p <= input.length()) out.append('.');
or
if (q < input.length()) out.append('.');
trailing dots will be preserved.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
System.out.println(java.net.IDN.toASCII("sun.com"));
System.out.println(java.net.IDN.toASCII("sun.com."));
System.out.println(java.net.IDN.toUnicode("sun.com"));
System.out.println(java.net.IDN.toUnicode("sun.com."));
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
sun.com
sun.com.
sun.com
sun.com.
ACTUAL -
sun.com
sun.com
sun.com
sun.com
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
It's possible to work around this bug by adding the missing dot in the calling code, but it's a kludge having to do this everywhere.
String toASCII(String hostname) {
boolean dot = hostname.endsWith(".");
hostname = IDN.toASCII(hostname);
if (dot && !hostname.endsWith(".")) {
hostname += "."
}
return hostname;
}
java version "1.6.0_15"
Java(TM) SE Runtime Environment (build 1.6.0_15-b03)
Java HotSpot(TM) 64-Bit Server VM (build 14.1-b02, mixed mode)
A DESCRIPTION OF THE PROBLEM :
The .toASCII and .toUnicode methods of java.net.IDN always return a hostname without a trailing dot, even when the input string did have a trailing dot. Because hostnames with and without a trailing dots are not semantically the same, I think a trailing dot should be preserved.
In both methods the following check is used to determine whether a dot should be added or not:
if (p < input.length()) out.append('.');
By changing this into
if (p <= input.length()) out.append('.');
or
if (q < input.length()) out.append('.');
trailing dots will be preserved.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
System.out.println(java.net.IDN.toASCII("sun.com"));
System.out.println(java.net.IDN.toASCII("sun.com."));
System.out.println(java.net.IDN.toUnicode("sun.com"));
System.out.println(java.net.IDN.toUnicode("sun.com."));
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
sun.com
sun.com.
sun.com
sun.com.
ACTUAL -
sun.com
sun.com
sun.com
sun.com
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
It's possible to work around this bug by adding the missing dot in the calling code, but it's a kludge having to do this everywhere.
String toASCII(String hostname) {
boolean dot = hostname.endsWith(".");
hostname = IDN.toASCII(hostname);
if (dot && !hostname.endsWith(".")) {
hostname += "."
}
return hostname;
}
- duplicates
-
JDK-8020842 IDN do not throw IAE when hostname ends with a trailing dot
-
- Closed
-