Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-29080

QUrl::fromAce() doesn't actually decode the punycoded domain

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 4.8.4
    • Core: URL Handling
    • None

    Description

      The documentation says QUrl::fromAce() is supposed to work with decoding a punycoded domain back to its original form. But it seems it's not.

      Test case:
      QUrl::fromAce("xn--6kry05bl4a"); // punycode of 南极星
      QUrl::fromAce("xn--6kry05bl4a.com");
      QUrl::fromAce("www.xn--6kry05bl4a.com");

      All these three lines of code return the string we passed in:
      xn--6kry05bl4a
      xn--6kry05bl4a.com
      www.xn--6kry05bl4a.com

      Looking into QUrl.cpp, it seems both fromAce and toAce use qt_ACE_do to do the punycode work but qt_ACE_do doesn't actually differentiate encoding or decoding.

      At line 3397:
      toPunycodeHelper(result.constData() + prevLen, result.size() - prevLen, &aceForm);

      It applies another to-punycode operation on the input and at line 3401:
      QString tmp = QUrl::fromPunycode(aceForm.toLatin1());

      It decodes the double-encoded string so the output is actually the same as the input. That said:
      fromAce(punycode) outputs punycode
      fromAce(non-punycode) outputs punycode

      Is this the expected behavior? If yes, is there a function we can use to decode the punycoded domain in QUrl? Thanks.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            seanzhu Sean Zhu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes