help-libidn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug: dot at the last position of hostName


From: Pavel Tarasenko
Subject: Bug: dot at the last position of hostName
Date: Fri, 13 Mar 2009 01:17:58 +0300

Version: libidn-1.9.jar

When calling method IDNA.toASCII() with argument like
"www.google.com." ( dot at the last position. It is correct usage. For
example, Firefox and IE treat this well. ) we get IDNAException:
String too long.


Possible solution:

    public static String  toASCII(String  input)   throws IDNAException {
        StringBuilder  o = new StringBuilder ();
        StringBuilder  h = new StringBuilder ();

        for (int i = 0; i < input.length(); i++) {
            char c = input.charAt(i);
            if (c == '.' || c == '\u3002' || c == '\uff0e' || c == '\uff61') {
                o.append(toASCII(h.toString(), false, true));
                o.append(c);
                h = new StringBuilder ();
            } else {
                h.append(c);
            }
        }

        if(h.length() != 0){    //
-------------------------------------------------------------  add
this line
             o.append(toASCII(h.toString(), false, true));

        return o.toString();
    }

-- 
Regards,
Tarasenko Pavel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]