diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2012-08-16 15:31:06 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-20 21:59:32 +0200 |
commit | ce9b010ec619aa6e5f19b6ae208b76a4e398b20b (patch) | |
tree | 7eccc6c7a4a5654dae1956df4a3f262dd8c0f109 /src/corelib/io/qurlquery.h | |
parent | 60818231d82ca34f1d33ccb9ba7500b5470a3d0d (diff) |
Fix decoding of QByteArray in the deprecated "encoded" setters in QUrl
The asymmetry is intentional: the getters can use toLatin1() because the
called functions, with a QUrl::FullyEncoded parameter, return ASCII
only. This gives a small performance improvement over the need to run
the UTF-8 encoder.
However, the data passed to setters could contain non-ASCII binary data,
in addition to the percent-encoded data. We can't use fromUtf8 because
it's binary and we can't use toPercentEncoded because it already encoded.
Change-Id: I5ecdb49be5af51ac86fd9764eb3a6aa96385f512
Reviewed-by: David Faure <faure@kde.org>
Diffstat (limited to 'src/corelib/io/qurlquery.h')
-rw-r--r-- | src/corelib/io/qurlquery.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/corelib/io/qurlquery.h b/src/corelib/io/qurlquery.h index 5eac44f327..c4bb359f3b 100644 --- a/src/corelib/io/qurlquery.h +++ b/src/corelib/io/qurlquery.h @@ -132,22 +132,22 @@ inline void QUrl::removeAllQueryItems(const QString &key) { QUrlQuery q(*this); q.removeAllQueryItems(key); } inline void QUrl::addEncodedQueryItem(const QByteArray &key, const QByteArray &value) -{ QUrlQuery q(*this); q.addQueryItem(QString::fromUtf8(key), QString::fromUtf8(value)); setQuery(q); } +{ QUrlQuery q(*this); q.addQueryItem(fromEncodedComponent_helper(key), fromEncodedComponent_helper(value)); setQuery(q); } inline bool QUrl::hasEncodedQueryItem(const QByteArray &key) const -{ return QUrlQuery(*this).hasQueryItem(QString::fromUtf8(key)); } +{ return QUrlQuery(*this).hasQueryItem(fromEncodedComponent_helper(key)); } inline QByteArray QUrl::encodedQueryItemValue(const QByteArray &key) const -{ return QUrlQuery(*this).queryItemValue(QString::fromUtf8(key), QUrl::FullyEncoded).toLatin1(); } +{ return QUrlQuery(*this).queryItemValue(fromEncodedComponent_helper(key), QUrl::FullyEncoded).toLatin1(); } inline void QUrl::removeEncodedQueryItem(const QByteArray &key) -{ QUrlQuery q(*this); q.removeQueryItem(QString::fromUtf8(key)); setQuery(q); } +{ QUrlQuery q(*this); q.removeQueryItem(fromEncodedComponent_helper(key)); setQuery(q); } inline void QUrl::removeAllEncodedQueryItems(const QByteArray &key) -{ QUrlQuery q(*this); q.removeAllQueryItems(QString::fromUtf8(key)); } +{ QUrlQuery q(*this); q.removeAllQueryItems(fromEncodedComponent_helper(key)); } inline void QUrl::setEncodedQueryItems(const QList<QPair<QByteArray, QByteArray> > &qry) { QUrlQuery q; QList<QPair<QByteArray, QByteArray> >::ConstIterator it = qry.constBegin(); for ( ; it != qry.constEnd(); ++it) - q.addQueryItem(QString::fromUtf8(it->first), QString::fromUtf8(it->second)); + q.addQueryItem(fromEncodedComponent_helper(it->first), fromEncodedComponent_helper(it->second)); setQuery(q); } inline QList<QPair<QByteArray, QByteArray> > QUrl::encodedQueryItems() const @@ -162,7 +162,7 @@ inline QList<QPair<QByteArray, QByteArray> > QUrl::encodedQueryItems() const } inline QList<QByteArray> QUrl::allEncodedQueryItemValues(const QByteArray &key) const { - QStringList items = QUrlQuery(*this).allQueryItemValues(QString::fromUtf8(key), QUrl::FullyEncoded); + QStringList items = QUrlQuery(*this).allQueryItemValues(fromEncodedComponent_helper(key), QUrl::FullyEncoded); QList<QByteArray> result; result.reserve(items.size()); Q_FOREACH (const QString &item, items) |