diff options
-rw-r--r-- | src/corelib/io/qurl.cpp | 11 | ||||
-rw-r--r-- | src/corelib/io/qurl.h | 4 | ||||
-rw-r--r-- | src/corelib/io/qurl_p.h | 1 | ||||
-rw-r--r-- | src/corelib/io/qurlrecode.cpp | 48 | ||||
-rw-r--r-- | tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp | 32 |
5 files changed, 0 insertions, 96 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index a85bb0e58c..615c814e91 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3013,17 +3013,6 @@ QByteArray QUrl::toPercentEncoding(const QString &input, const QByteArray &exclu } /*! - \internal - \since 5.0 - Used in the setEncodedXXX compatibility functions. Converts \a ba to - QString form. -*/ -QString QUrl::fromEncodedComponent_helper(const QByteArray &ba) -{ - return qt_urlRecodeByteArray(ba); -} - -/*! \fn QByteArray QUrl::toPunycode(const QString &uc) \obsolete Returns a \a uc in Punycode encoding. diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h index 1972251898..043b3b1482 100644 --- a/src/corelib/io/qurl.h +++ b/src/corelib/io/qurl.h @@ -279,10 +279,6 @@ public: NSURL *toNSURL() const Q_DECL_NS_RETURNS_AUTORELEASED; #endif -private: - static QString fromEncodedComponent_helper(const QByteArray &ba); - -public: static QString fromAce(const QByteArray &); static QByteArray toAce(const QString &); static QStringList idnWhitelist(); diff --git a/src/corelib/io/qurl_p.h b/src/corelib/io/qurl_p.h index 9a063a37e6..3d4a04928d 100644 --- a/src/corelib/io/qurl_p.h +++ b/src/corelib/io/qurl_p.h @@ -70,7 +70,6 @@ extern Q_AUTOTEST_EXPORT bool qt_nameprep(QString *source, int from); extern Q_AUTOTEST_EXPORT bool qt_check_std3rules(QStringView in); extern Q_AUTOTEST_EXPORT void qt_punycodeEncoder(QStringView in, QString *output); extern Q_AUTOTEST_EXPORT QString qt_punycodeDecoder(const QString &pc); -extern Q_AUTOTEST_EXPORT QString qt_urlRecodeByteArray(const QByteArray &ba); QT_END_NAMESPACE diff --git a/src/corelib/io/qurlrecode.cpp b/src/corelib/io/qurlrecode.cpp index ad23588978..2ac335cf5c 100644 --- a/src/corelib/io/qurlrecode.cpp +++ b/src/corelib/io/qurlrecode.cpp @@ -695,52 +695,4 @@ qt_urlRecode(QString &appendTo, QStringView in, encoding, actionTable, false); } -// qstring.cpp -bool qt_is_ascii(const char *&ptr, const char *end) noexcept; - -/*! - \internal - \since 5.0 - - \a ba contains an 8-bit form of the component and it might be - percent-encoded already. We can't use QString::fromUtf8 because it might - contain non-UTF8 sequences. We can't use QByteArray::toPercentEncoding - because it might already contain percent-encoded sequences. We can't use - qt_urlRecode because it needs UTF-16 input. -*/ -Q_AUTOTEST_EXPORT -QString qt_urlRecodeByteArray(const QByteArray &ba) -{ - if (ba.isNull()) - return QString(); - - // scan ba for anything above or equal to 0x80 - // control points below 0x20 are fine in QString - const char *in = ba.constData(); - const char *const end = ba.constEnd(); - if (qt_is_ascii(in, end)) { - // no non-ASCII found, we're safe to convert to QString - return QString::fromLatin1(ba, ba.size()); - } - - // we found something that we need to encode - QByteArray intermediate = ba; - intermediate.resize(ba.size() * 3 - (in - ba.constData())); - uchar *out = reinterpret_cast<uchar *>(intermediate.data() + (in - ba.constData())); - for ( ; in < end; ++in) { - if (*in & 0x80) { - // encode - *out++ = '%'; - *out++ = encodeNibble(uchar(*in) >> 4); - *out++ = encodeNibble(uchar(*in) & 0xf); - } else { - // keep - *out++ = uchar(*in); - } - } - - // now it's safe to call fromLatin1 - return QString::fromLatin1(intermediate, out - reinterpret_cast<uchar *>(intermediate.data())); -} - QT_END_NAMESPACE diff --git a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp index 452f9417e1..da9477ca84 100644 --- a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp +++ b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp @@ -84,8 +84,6 @@ private Q_SLOTS: void encodingRecode(); void encodingRecodeInvalidUtf8_data(); void encodingRecodeInvalidUtf8(); - void recodeByteArray_data(); - void recodeByteArray(); }; #include "tst_qurlinternal.moc" @@ -1067,34 +1065,4 @@ void tst_QUrlInternal::encodingRecodeInvalidUtf8() } } -void tst_QUrlInternal::recodeByteArray_data() -{ - QTest::addColumn<QByteArray>("input"); - QTest::addColumn<QString>("expected"); - - QTest::newRow("null") << QByteArray() << QString(); - QTest::newRow("empty") << QByteArray("") << QString(""); - QTest::newRow("normal") << QByteArray("Hello") << "Hello"; - QTest::newRow("valid-utf8") << QByteArray("\xc3\xa9") << "%C3%A9"; - QTest::newRow("percent-encoded") << QByteArray("%C3%A9%00%C0%80") << "%C3%A9%00%C0%80"; - QTest::newRow("invalid-utf8-1") << QByteArray("\xc3\xc3") << "%C3%C3"; - QTest::newRow("invalid-utf8-2") << QByteArray("\xc0\x80") << "%C0%80"; - - // note: percent-encoding the control characters ("\0" -> "%00") would also - // be correct, but it's unnecessary for this function - QTest::newRow("binary") << QByteArray("\0\x1f", 2) << QString::fromLatin1("\0\x1f", 2);; - QTest::newRow("binary+percent-encoded") << QByteArray("\0%25", 4) << QString::fromLatin1("\0%25", 4); -} - -void tst_QUrlInternal::recodeByteArray() -{ - QFETCH(QByteArray, input); - QFETCH(QString, expected); - QString output = qt_urlRecodeByteArray(input); - - QCOMPARE(output.isNull(), input.isNull()); - QCOMPARE(output.isEmpty(), input.isEmpty()); - QCOMPARE(output, expected); -} - QTEST_APPLESS_MAIN(tst_QUrlInternal) |