diff options
author | Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io> | 2021-08-10 14:30:10 +0200 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2021-08-11 19:12:00 +0000 |
commit | 2b4ffe914f191f598ae8e9639ad1efd3179e4b46 (patch) | |
tree | 7391be5d358b30726d99c0c0a7e99a6c5d7c7600 /src/corelib/io/qurlidna.cpp | |
parent | 22bf38351954137ff17e9a314f8847ee1fd00234 (diff) |
QUrl: Fix handling of invalid sequences starting with xn--
Return ASCII sequences that start with xn-- but fail Punycode
decoding as is when converting URLs to Unicode. This is consistent
with handling of sequences that do decode successfully but fail other
validity checks.
This fixes one test in tst_qurlinternal.
Task-number: QTBUG-95689
Pick-to: 6.2
Change-Id: I63d7197f25102c96f5dc21d9fecec5e015c531cb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qurlidna.cpp')
-rw-r--r-- | src/corelib/io/qurlidna.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/corelib/io/qurlidna.cpp b/src/corelib/io/qurlidna.cpp index c1a5220dbb..5621fa83a3 100644 --- a/src/corelib/io/qurlidna.cpp +++ b/src/corelib/io/qurlidna.cpp @@ -2596,10 +2596,13 @@ QString qt_ACE_do(QStringView domain, AceOperation op, AceLeadingDot dot) // We use resize()+memcpy() here because we're overwriting the data we've copied bool appended = false; if (isIdnEnabled) { + // The decoding step can fail here if the original domain name contained + // labels that start with "xn--" but don't contain valid Punycode. Even + // if the label was decoded correctly, it may still break some IDNA rules. + // In either case the original ASCII label should be used instead of + // the result returned by the decoder. QString tmp = qt_punycodeDecoder(aceForm); - if (tmp.isEmpty()) - return QString(); // shouldn't happen, since we've just punycode-encoded it - if (qt_check_nameprepped_std3(tmp)) { + if (!tmp.isEmpty() && qt_check_nameprepped_std3(tmp)) { result.resize(prevLen + tmp.size()); memcpy(result.data() + prevLen, tmp.constData(), tmp.size() * sizeof(QChar)); appended = true; |