Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
4.8.4
-
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.