addon to 8230613: Better ASCII conversions ?

Baesken, Matthias matthias.baesken at sap.com
Thu Jul 16 12:19:34 UTC 2020


Hi Alan, I do not have such a test case .
Is there one for the  change 8230613 ?

The only call to Punycode.encode in IDN.java  is  below and the coding intends to catch java.text.ParseException  from  Punycode.encode
and then throws an IllegalArgumentException . I see nothing  regarding  RuntimeException  in IDN .


jdk/src/java.base/share/classes/java/net/IDN.java


260    private static String toASCIIInternal(String label, int flag)
          .....
312            if (!isAllASCII(dest.toString())) {
313                // step 5
314                // verify the sequence does not begin with ACE prefix
315                if(!startsWithACEPrefix(dest)){
316
317                    // step 6
318                    // encode the sequence with punycode
319                    try {
320                        dest = Punycode.encode(dest, null);
321                    } catch (java.text.ParseException e) {
322                        throw new IllegalArgumentException(e);
323                    }
324
325                    dest = toASCIILower(dest);
326
327                    // step 7
328                    // prepend the ACE prefix
329                    dest.insert(0, ACE_PREFIX);
330                } else {
331                    throw new IllegalArgumentException("The input starts with the ACE Prefix");
332                }

Best regards, Matthias


>> Hello, recent change
>>
>> https://hg.openjdk.java.net/jdk/jdk/rev/9e70cd55ae08
>>
>> 8230613: Better ASCII conversions
>>
>> Adjusted one place  in  file Punycode.java   to throw  the declared ParseException in
>>
>>      public static StringBuffer encode(StringBuffer src, boolean[] caseFlags) throws ParseException{  ...  }
>>
>> I think we should  better adjust  the  remaining  throw   in  the same method  as well to a ParseException .  See  small patch below.
>> Should I open a JBS  issue  for this ?
>>
>I wonder if it is possible to create a test case that uses IDN.toASCII 
>and trickles this case in Punnycode. In passing, it might be that the 
>IAE specified by toASCII needs clarification for the additional cases 
>where it will reject input.



More information about the core-libs-dev mailing list