Fix cookie path matching for empty url path
The path wouldn't match if the cookie's path was root ('/') and the
URLs path was empty.
Change-Id: I6dcd10f1fdf4f48f14e50f1b169cbdfda7005849
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
bb10
parent
f13e75345d
commit
fc98878658
|
|
@ -140,7 +140,7 @@ void QNetworkCookieJar::setAllCookies(const QList<QNetworkCookie> &cookieList)
|
|||
|
||||
static inline bool isParentPath(const QString &path, const QString &reference)
|
||||
{
|
||||
if (path.startsWith(reference)) {
|
||||
if ((path.isEmpty() && reference == QLatin1String("/")) || path.startsWith(reference)) {
|
||||
//The cookie-path and the request-path are identical.
|
||||
if (path.length() == reference.length())
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -340,6 +340,17 @@ void tst_QNetworkCookieJar::cookiesForUrl_data()
|
|||
QTest::newRow("no-match-domain-dot") << allCookies << "http://example.com" << result;
|
||||
result += cookieDot;
|
||||
QTest::newRow("match-domain-dot") << allCookies << "http://example.com." << result;
|
||||
|
||||
// Root path in cookie, empty url path
|
||||
allCookies.clear();
|
||||
QNetworkCookie rootCookie;
|
||||
rootCookie.setName("a");
|
||||
rootCookie.setPath("/");
|
||||
rootCookie.setDomain("qt-project.org");
|
||||
allCookies += rootCookie;
|
||||
result.clear();
|
||||
result += rootCookie;
|
||||
QTest::newRow("root-path-match") << allCookies << "http://qt-project.org" << result;
|
||||
}
|
||||
|
||||
void tst_QNetworkCookieJar::cookiesForUrl()
|
||||
|
|
|
|||
Loading…
Reference in New Issue