diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp index dde262e7797..fe45127718c 100644 --- a/src/corelib/compat/removed_api.cpp +++ b/src/corelib/compat/removed_api.cpp @@ -615,3 +615,18 @@ QStringView QXmlStreamAttributes::value(QLatin1StringView qualifiedName) const // order sections alphabetically to reduce chances of merge conflicts #endif // QT_CORE_REMOVED_SINCE(6, 6) + +#if QT_CORE_REMOVED_SINCE(6, 7) + +#include "qurl.h" + +QUrl QUrl::fromEncoded(const QByteArray &input, ParsingMode mode) +{ + return QUrl::fromEncoded(QByteArrayView(input), mode); +} + +// #include "qotherheader.h" +// // implement removed functions from qotherheader.h +// order sections alphabetically to reduce chances of merge conflicts + +#endif // QT_CORE_REMOVED_SINCE(6, 7) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index b6f4d00c152..bb5879c9c4d 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -2968,19 +2968,23 @@ QByteArray QUrl::toEncoded(FormattingOptions options) const } /*! - \fn QUrl QUrl::fromEncoded(const QByteArray &input, ParsingMode parsingMode) - Parses \a input and returns the corresponding QUrl. \a input is assumed to be in encoded form, containing only ASCII characters. Parses the URL using \a parsingMode. See setUrl() for more information on this parameter. QUrl::DecodedMode is not permitted in this context. + \note In Qt versions prior to 6.7, this function took a QByteArray, not + QByteArrayView. If you experience compile errors, it's because your code + is passing objects that are implicitly convertible to QByteArray, but not + QByteArrayView. Wrap the corresponding argument in \c{QByteArray{~~~}} to + make the cast explicit. This is backwards-compatible with old Qt versions. + \sa toEncoded(), setUrl() */ -QUrl QUrl::fromEncoded(const QByteArray &input, ParsingMode mode) +QUrl QUrl::fromEncoded(QByteArrayView input, ParsingMode mode) { - return QUrl(QString::fromUtf8(input.constData(), input.size()), mode); + return QUrl(QString::fromUtf8(input), mode); } /*! diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h index 7922149bd8b..b84348b650f 100644 --- a/src/corelib/io/qurl.h +++ b/src/corelib/io/qurl.h @@ -165,7 +165,10 @@ public: [[nodiscard]] QUrl adjusted(FormattingOptions options) const; QByteArray toEncoded(FormattingOptions options = FullyEncoded) const; +#if QT_CORE_REMOVED_SINCE(6, 7) static QUrl fromEncoded(const QByteArray &url, ParsingMode mode = TolerantMode); +#endif + static QUrl fromEncoded(QByteArrayView input, ParsingMode mode = TolerantMode); enum UserInputResolutionOption { DefaultResolution,