mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 19:02:59 +00:00
convert input domain to UTF-8 in QUrl::fromAce()
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
82fb75adb5
commit
2ecefbccc3
1 changed files with 3 additions and 2 deletions
|
@ -3526,17 +3526,18 @@ QString QUrl::fromAce(const QByteArray &domain)
|
||||||
return QByteArray();
|
return QByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString utf8 = QString::fromUtf8(domain);
|
||||||
UErrorCode error = U_ZERO_ERROR;
|
UErrorCode error = U_ZERO_ERROR;
|
||||||
UIDNAInfo info = UIDNA_INFO_INITIALIZER;
|
UIDNAInfo info = UIDNA_INFO_INITIALIZER;
|
||||||
QString result(domain.size() * 4, Qt::Uninitialized);
|
QString result(domain.size() * 4, Qt::Uninitialized);
|
||||||
const int idnaresult = uidna_nameToUnicode(globalidna,
|
const int idnaresult = uidna_nameToUnicode(globalidna,
|
||||||
reinterpret_cast<const UChar*>(domain.constData()), domain.size(),
|
reinterpret_cast<const UChar*>(utf8.constData()), utf8.size(),
|
||||||
reinterpret_cast<UChar*>(result.data()), result.size(),
|
reinterpret_cast<UChar*>(result.data()), result.size(),
|
||||||
&info, &error);
|
&info, &error);
|
||||||
|
|
||||||
if (Q_UNLIKELY(U_FAILURE(error) && info.errors != 0)) {
|
if (Q_UNLIKELY(U_FAILURE(error) && info.errors != 0)) {
|
||||||
qWarning("QUrl::fromAce: failed %s", u_errorName(error));
|
qWarning("QUrl::fromAce: failed %s", u_errorName(error));
|
||||||
return QString::fromUtf8(domain);
|
return utf8;
|
||||||
}
|
}
|
||||||
|
|
||||||
result.resize(idnaresult);
|
result.resize(idnaresult);
|
||||||
|
|
Loading…
Add table
Reference in a new issue