Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.0.0
-
None
-
79b14f42ba2062252bad5e5ad7c7986b967f6f6a
Description
We see a regression when passing a query string to QUrl::setEncodedQueryItems.
The string get added to the query string that may already be present in the
url. It used to replace any existing query string.
The API documentation indicates that the passed query items are set to quesry
string of url. Also, presence of equvalent add* functions (as opposed to set*
suggest that the setters replace.
Example code.
main.cpp
#include <QUrl> #include <QPair> #include <QList> #include <QDebug> typedef QPair<QByteArray, QByteArray> EncodedQueryItem; int main(int, char**) { QUrl url("http://example.com"); QList<EncodedQueryItem> list; list.append(EncodedQueryItem("foo", "123")); url.setEncodedQueryItems(list); list.clear(); list.append(EncodedQueryItem("bar", "456")); url.setEncodedQueryItems(list); qDebug() << "Expected: \"http://example.com?bar=456\""; qDebug() << "Actual: " << url.toString(); return 0; }
Below are the result we get running the example code.
Expected: "http://example.com?bar=456" Actual: "http://example.com?foo=123&bar=456"
Attachments
For Gerrit Dashboard: QTBUG-26148 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
28683,3 | QUrl::setEncodedQueryItems should replace | master | qt/qtbase | Status: MERGED | +2 | 0 |