From c15560fbe2a1762117395c5ecaaecfa5ab8dce6f Mon Sep 17 00:00:00 2001 From: Perttu Pohjonen Date: Mon, 7 Mar 2011 08:49:00 +0200 Subject: Unsuccessful unlocking of QNetworkConfigurationPrivate mutex Above mentioned mutex is locked twice: first in caller function and second time in called function. Called function unlocks mutex and emits signal clearly unaware that the mutex is actually still locked. I changed the mutex to be unlocked before the function is called. Task-number: QTBUG-15108 Reviewed-by: Ville Pernu --- src/plugins/bearer/symbian/symbianengine.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index fc480c2..e315d9f 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -829,6 +829,7 @@ void SymbianEngine::updateStatesToSnaps() discovered = true; } } + snapConfigLocker.unlock(); if (active) { changeConfigurationStateTo(ptr, QNetworkConfiguration::Active); } else if (discovered) { -- cgit v0.12 From 3904e8cadc0c4a3c80c5958451f8f130f523ed08 Mon Sep 17 00:00:00 2001 From: Aparna Nandyal Date: Tue, 1 Mar 2011 11:34:09 +0100 Subject: Fix for QTBUG-17746. Quotes is retained in cookie value Merge-request: 1118 Task-number: QTBUG-17746 Reviewed-by: Peter Hartmann --- src/network/access/qnetworkcookie.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index 70ea5c2..3484217 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -359,7 +359,7 @@ void QNetworkCookie::setValue(const QByteArray &value) } // ### move this to qnetworkcookie_p.h and share with qnetworkaccesshttpbackend -static QPair nextField(const QByteArray &text, int &position) +static QPair nextField(const QByteArray &text, int &position, bool isNameValue) { // format is one of: // (1) token @@ -394,10 +394,14 @@ static QPair nextField(const QByteArray &text, int &posi // quoted-string = ( <"> *(qdtext | quoted-pair ) <"> ) // qdtext = > // quoted-pair = "\" CHAR - ++i; + + // If its NAME=VALUE, retain the value as is + // refer to ttp://bugreports.qt.nokia.com/browse/QTBUG-17746 + if (!isNameValue) + ++i; while (i < length) { register char c = text.at(i); - if (c == '"') { + if (c == '"' && !isNameValue) { // end of quoted text break; } else if (c == '\\') { @@ -406,6 +410,8 @@ static QPair nextField(const QByteArray &text, int &posi // broken line return qMakePair(QByteArray(), QByteArray()); c = text.at(i); + } else if ((c == ';' || c == ',') && isNameValue) { + break; } second += c; @@ -476,10 +482,12 @@ QByteArray QNetworkCookie::toRawForm(RawForm form) const result = d->name; result += '='; - if (d->value.contains(';') || + if ((d->value.contains(';') || d->value.contains(',') || d->value.contains(' ') || - d->value.contains('"')) { + d->value.contains('"')) && + (!d->value.startsWith('"') && + !d->value.endsWith('"'))) { result += '"'; QByteArray value = d->value; @@ -947,7 +955,7 @@ QList QNetworkCookiePrivate::parseSetCookieHeaderLine(const QByt QNetworkCookie cookie; // The first part is always the "NAME=VALUE" part - QPair field = nextField(cookieString, position); + QPair field = nextField(cookieString, position, true); if (field.first.isEmpty() || field.second.isNull()) // parsing error break; @@ -965,7 +973,7 @@ QList QNetworkCookiePrivate::parseSetCookieHeaderLine(const QByt case ';': // new field in the cookie - field = nextField(cookieString, position); + field = nextField(cookieString, position, false); field.first = field.first.toLower(); // everything but the NAME=VALUE is case-insensitive if (field.first == "expires") { -- cgit v0.12 From ca70c91ccc11450b0e634fd6054f1497c7c2a6ed Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Tue, 1 Mar 2011 19:18:54 +0100 Subject: QNetworkCookie: fix quoted values Do not strip quotes etc. from cookie values; from the RFC 2109: "The VALUE is opaque to the user agent (...)". In addition, escaped quotes are allowed in quoted values. Reviewed-by: Markus Goetz Task-number: QTBUG-17746 --- src/network/access/qnetworkcookie.cpp | 13 ++++++++----- tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp | 24 ++++++++++++++++-------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index 3484217..c2a6925 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -397,21 +397,24 @@ static QPair nextField(const QByteArray &text, int &posi // If its NAME=VALUE, retain the value as is // refer to ttp://bugreports.qt.nokia.com/browse/QTBUG-17746 - if (!isNameValue) - ++i; + if (isNameValue) + second += '"'; + ++i; while (i < length) { register char c = text.at(i); - if (c == '"' && !isNameValue) { + if (c == '"') { // end of quoted text + if (isNameValue) + second += '"'; break; } else if (c == '\\') { + if (isNameValue) + second += '\\'; ++i; if (i >= length) // broken line return qMakePair(QByteArray(), QByteArray()); c = text.at(i); - } else if ((c == ';' || c == ',') && isNameValue) { - break; } second += c; diff --git a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp index 0c89013..91dfe47 100644 --- a/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp +++ b/tests/auto/qnetworkcookie/tst_qnetworkcookie.cpp @@ -171,16 +171,16 @@ void tst_QNetworkCookie::parseSingleCookie_data() QTest::newRow("with-value7") << "a = b" << cookie; QTest::newRow("with-value8") << "a = b " << cookie; - cookie.setValue(","); + cookie.setValue("\",\""); QTest::newRow("with-value-with-special1") << "a = \",\" " << cookie; - cookie.setValue(";"); + cookie.setValue("\";\""); QTest::newRow("with-value-with-special2") << "a = \";\" " << cookie; - cookie.setValue(" "); + cookie.setValue("\" \""); QTest::newRow("with-value-with-special3") << "a = \" \" " << cookie; - cookie.setValue("\""); - QTest::newRow("with-value-with-special3") << "a = \"\\\"\" " << cookie; - cookie.setValue("\"a, b; c\""); - QTest::newRow("with-value-with-special4") << "a = \"\\\"a, b; c\\\"\"" << cookie; + cookie.setValue("\"\\\"\""); + QTest::newRow("with-value-with-special4") << "a = \"\\\"\" " << cookie; + cookie.setValue("\"\\\"a, b; c\\\"\""); + QTest::newRow("with-value-with-special5") << "a = \"\\\"a, b; c\\\"\"" << cookie; cookie.setValue("b"); cookie.setSecure(true); @@ -568,10 +568,18 @@ void tst_QNetworkCookie::parseSingleCookie_data() cookie.setDomain("mail.yahoo.com"); QTest::newRow("network3") << "YM.LC=v=2&m=9993_262838_159_1558_1063_0_5649_4012_3776161073,9426_260205_549_1295_1336_0_5141_4738_3922731647,6733_258196_952_1364_643_0_3560_-1_0,3677_237633_1294_1294_19267_0_3244_29483_4102206176,1315_235149_1693_1541_941_0_3224_1691_1861378060,1858_214311_2100_1298_19538_0_2873_30900_716411652,6258_212007_2506_1285_1017_0_2868_3606_4288540264,3743_207884_2895_1362_2759_0_2545_7114_3388520216,2654_205253_3257_1297_1332_0_2504_4682_3048534803,1891_184881_3660_1291_19079_0_978_29178_2592538685&f=1&n=20&s=date&o=down&e=1196548712&b=Inbox&u=removed; path=/; domain=mail.yahoo.com" << cookie; - cookie = QNetworkCookie("__ac", "c2hhdXNtYW46U2FTYW80Wm8%3D"); + cookie = QNetworkCookie("__ac", "\"c2hhdXNtYW46U2FTYW80Wm8%3D\""); cookie.setPath("/"); cookie.setExpirationDate(QDateTime(QDate(2008, 8, 30), QTime(20, 21, 49), Qt::UTC)); QTest::newRow("network4") << "__ac=\"c2hhdXNtYW46U2FTYW80Wm8%3D\"; Path=/; Expires=Sat, 30 Aug 2008 20:21:49 +0000" << cookie; + + // linkedin.com sends cookies in quotes and expects the cookie in quotes + cookie = QNetworkCookie("leo_auth_token", "\"GST:UroVXaxYA3sVSkoVjMNH9bj4dZxVzK2yekgrAUxMfUsyLTNyPjoP60:1298974875:b675566ae32ab36d7a708c0efbf446a5c22b9fca\""); + cookie.setPath("/"); + cookie.setExpirationDate(QDateTime(QDate(2011, 3, 1), QTime(10, 51, 14), Qt::UTC)); + QTest::newRow("network5") << "leo_auth_token=\"GST:UroVXaxYA3sVSkoVjMNH9bj4dZxVzK2yekgrAUxMfUsyLTNyPjoP60:1298974875:b675566ae32ab36d7a708c0efbf446a5c22b9fca\"; Version=1; Max-Age=1799; Expires=Tue, 01-Mar-2011 10:51:14 GMT; Path=/" << cookie; + + } void tst_QNetworkCookie::parseSingleCookie() -- cgit v0.12 From c0756297da324069839622217e3cb38c8a745e33 Mon Sep 17 00:00:00 2001 From: Cristiano di Flora Date: Tue, 8 Mar 2011 16:55:52 +0200 Subject: Fix possible bearer management Crash with Panic E32USER-CBase, 69 Task-Number: QT-4652 Reviewed-by: Xizhi Zhu --- src/plugins/bearer/symbian/symbianengine.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index e315d9f..f367c26 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -150,16 +150,15 @@ SymbianEngine::~SymbianEngine() iConnectionMonitor.CancelNotifications(); iConnectionMonitor.Close(); - -#ifdef SNAP_FUNCTIONALITY_AVAILABLE - iCmManager.Close(); -#endif - - // CCommsDatabase destructor uses cleanup stack. Since QNetworkConfigurationManager + + // CCommsDatabase destructor and RCmManager.Close() use cleanup stack. Since QNetworkConfigurationManager // is a global static, but the time we are here, E32Main() has been exited already and // the thread's default cleanup stack has been deleted. Without this line, a // 'E32USER-CBase 69' -panic will occur. CTrapCleanup* cleanup = CTrapCleanup::New(); +#ifdef SNAP_FUNCTIONALITY_AVAILABLE + iCmManager.Close(); +#endif delete ipCommsDB; delete cleanup; } -- cgit v0.12