qnetworkcookiejar.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/access/qnetworkcookiejar.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4QNetworkCookieJar::QNetworkCookieJar(QObject *parent)-
5 : QObject(*new QNetworkCookieJarPrivate, parent)-
6{-
7}
executed 285 times by 1 test: end of block
Executed by:
  • tst_qnetworkcookiejar - unknown status
285
8QNetworkCookieJar::~QNetworkCookieJar()-
9{-
10}-
11QList<QNetworkCookie> QNetworkCookieJar::allCookies() const-
12{-
13 return
executed 37 times by 2 tests: return d_func()->allCookies;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
d_func()->allCookies;
executed 37 times by 2 tests: return d_func()->allCookies;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
37
14}-
15void QNetworkCookieJar::setAllCookies(const QList<QNetworkCookie> &cookieList)-
16{-
17 QNetworkCookieJarPrivate * const d = d_func();-
18 d->allCookies = cookieList;-
19}
executed 719 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
719
20-
21static inline bool isParentPath(const QString &path, const QString &reference)-
22{-
23 if (path.startsWith(reference)
path.startsWith(reference)Description
TRUEevaluated 205 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 44 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
) {
44-205
24-
25 if (path.length() == reference.length()
path.length() ...rence.length()Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 181 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
)
24-181
26 return
executed 24 times by 1 test: return true;
Executed by:
  • tst_qnetworkcookiejar - unknown status
true;
executed 24 times by 1 test: return true;
Executed by:
  • tst_qnetworkcookiejar - unknown status
24
27-
28-
29 if (reference.endsWith('/')
reference.endsWith('/')Description
TRUEevaluated 160 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 21 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
)
21-160
30 return
executed 160 times by 2 tests: return true;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
true;
executed 160 times by 2 tests: return true;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
160
31-
32-
33-
34 if (path.at(reference.length()) == '/'
path.at(refere...ngth()) == '/'Description
TRUEevaluated 19 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
)
2-19
35 return
executed 19 times by 2 tests: return true;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
true;
executed 19 times by 2 tests: return true;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
19
36 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_qnetworkcookiejar - unknown status
2
37 return
executed 46 times by 2 tests: return false;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
false;
executed 46 times by 2 tests: return false;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
46
38}-
39-
40static inline bool isParentDomain(const QString &domain, const QString &reference)-
41{-
42 if (!reference.startsWith(QLatin1Char('.'))
!reference.sta...tin1Char('.'))Description
TRUEevaluated 439 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 149 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
)
149-439
43 return
executed 439 times by 2 tests: return domain == reference;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
domain == reference;
executed 439 times by 2 tests: return domain == reference;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
439
44-
45 return
executed 149 times by 2 tests: return domain.endsWith(reference) || domain == reference.midRef(1);
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
domain.endsWith(reference) || domain == reference.midRef(1);
executed 149 times by 2 tests: return domain.endsWith(reference) || domain == reference.midRef(1);
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
149
46}-
47bool QNetworkCookieJar::setCookiesFromUrl(const QList<QNetworkCookie> &cookieList,-
48 const QUrl &url)-
49{-
50 bool added = false;-
51 for (QNetworkCookie cookie : cookieList) {-
52 cookie.normalize(url);-
53 if (validateCookie(cookie, url)
validateCookie(cookie, url)Description
TRUEevaluated 234 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 22 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
&& insertCookie(cookie)
insertCookie(cookie)Description
TRUEevaluated 222 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
)
12-234
54 added = true;
executed 222 times by 2 tests: added = true;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
222
55 }
executed 256 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
256
56 return
executed 254 times by 2 tests: return added;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
added;
executed 254 times by 2 tests: return added;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
254
57}-
58QList<QNetworkCookie> QNetworkCookieJar::cookiesForUrl(const QUrl &url) const-
59{-
60-
61-
62-
63-
64-
65 const QNetworkCookieJarPrivate * const d = d_func();-
66 const QDateTime now = QDateTime::currentDateTimeUtc();-
67 QList<QNetworkCookie> result;-
68 bool isEncrypted = url.scheme() == QLatin1String("https");-
69-
70-
71 QList<QNetworkCookie>::ConstIterator it = d->allCookies.constBegin(),-
72 end = d->allCookies.constEnd();-
73 for ( ; it != end
it != endDescription
TRUEevaluated 269 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 911 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
; ++it) {
269-911
74 if (!isParentDomain(url.host(), it->domain())
!isParentDomai... it->domain())Description
TRUEevaluated 20 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 249 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
)
20-249
75 continue;
executed 20 times by 2 tests: continue;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
20
76 if (!isParentPath(url.path(), it->path())
!isParentPath(...), it->path())Description
TRUEevaluated 46 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 203 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
)
46-203
77 continue;
executed 46 times by 2 tests: continue;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
46
78 if (!(*it).isSessionCookie()
!(*it).isSessionCookie()Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 190 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
&& (*
(*it).expirationDate() < nowDescription
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
it).expirationDate() < now
(*it).expirationDate() < nowDescription
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
)
0-190
79 continue;
never executed: continue;
0
80 if ((*
(*it).isSecure()Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 185 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
it).isSecure()
(*it).isSecure()Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 185 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
&& !isEncrypted
!isEncryptedDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
)
2-185
81 continue;
executed 16 times by 1 test: continue;
Executed by:
  • tst_qnetworkcookiejar - unknown status
16
82-
83-
84 QList<QNetworkCookie>::Iterator insertIt = result.begin();-
85 while (insertIt != result.end()
insertIt != result.end()Description
TRUEevaluated 28 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 177 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
) {
28-177
86 if (insertIt->path().length() < it->path().length()
insertIt->path...ath().length()Description
TRUEevaluated 10 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
) {
10-18
87-
88 insertIt = result.insert(insertIt, *it);-
89 break;
executed 10 times by 2 tests: break;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
10
90 } else {-
91 ++insertIt;-
92 }
executed 18 times by 1 test: end of block
Executed by:
  • tst_qnetworkcookiejar - unknown status
18
93 }-
94-
95-
96 if (insertIt == result.end()
insertIt == result.end()Description
TRUEevaluated 177 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 10 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
)
10-177
97 result += *it;
executed 177 times by 2 tests: result += *it;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
177
98 }
executed 187 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
187
99-
100 return
executed 911 times by 2 tests: return result;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
result;
executed 911 times by 2 tests: return result;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
911
101}-
102bool QNetworkCookieJar::insertCookie(const QNetworkCookie &cookie)-
103{-
104 QNetworkCookieJarPrivate * const d = d_func();-
105 const QDateTime now = QDateTime::currentDateTimeUtc();-
106 bool isDeletion = !cookie.isSessionCookie()
!cookie.isSessionCookie()Description
TRUEevaluated 28 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 206 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
&&
28-206
107 cookie.expirationDate() < now
cookie.expirationDate() < nowDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 16 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
;
12-16
108-
109 deleteCookie(cookie);-
110-
111 if (!isDeletion
!isDeletionDescription
TRUEevaluated 222 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 12 times by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
) {
12-222
112 d->allCookies += cookie;-
113 return
executed 222 times by 2 tests: return true;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
true;
executed 222 times by 2 tests: return true;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
222
114 }-
115 return
executed 12 times by 1 test: return false;
Executed by:
  • tst_qnetworkcookiejar - unknown status
false;
executed 12 times by 1 test: return false;
Executed by:
  • tst_qnetworkcookiejar - unknown status
12
116}-
117bool QNetworkCookieJar::updateCookie(const QNetworkCookie &cookie)-
118{-
119 if (deleteCookie(cookie)
deleteCookie(cookie)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
120 return
never executed: return insertCookie(cookie);
insertCookie(cookie);
never executed: return insertCookie(cookie);
0
121 return
never executed: return false;
false;
never executed: return false;
0
122}-
123bool QNetworkCookieJar::deleteCookie(const QNetworkCookie &cookie)-
124{-
125 QNetworkCookieJarPrivate * const d = d_func();-
126 QList<QNetworkCookie>::Iterator it;-
127 for (it = d->allCookies.begin(); it != d->allCookies.end()
it != d->allCookies.end()Description
TRUEevaluated 45 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 227 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
; ++it) {
45-227
128 if (it->hasSameIdentifier(cookie)
it->hasSameIdentifier(cookie)Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 38 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
) {
7-38
129 d->allCookies.erase(it);-
130 return
executed 7 times by 1 test: return true;
Executed by:
  • tst_qnetworkcookiejar - unknown status
true;
executed 7 times by 1 test: return true;
Executed by:
  • tst_qnetworkcookiejar - unknown status
7
131 }-
132 }
executed 38 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
38
133 return
executed 227 times by 2 tests: return false;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
false;
executed 227 times by 2 tests: return false;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
227
134}-
135-
136-
137-
138-
139-
140-
141-
142bool QNetworkCookieJar::validateCookie(const QNetworkCookie &cookie, const QUrl &url) const-
143{-
144 QString domain = cookie.domain();-
145 const QString host = url.host();-
146 if (!isParentDomain(domain, host)
!isParentDomain(domain, host)Description
TRUEevaluated 63 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 193 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
&& !isParentDomain(host, domain)
!isParentDomain(host, domain)Description
TRUEevaluated 15 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 48 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
)
15-193
147 return
executed 15 times by 2 tests: return false;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
false;
executed 15 times by 2 tests: return false;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
15
148-
149-
150-
151-
152 if (qIsEffectiveTLD(domain.startsWith('.') ? domain.remove(0, 1) : domain)
qIsEffectiveTL..., 1) : domain)Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 234 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
)
7-234
153 return
executed 7 times by 1 test: return false;
Executed by:
  • tst_qnetworkcookiejar - unknown status
false;
executed 7 times by 1 test: return false;
Executed by:
  • tst_qnetworkcookiejar - unknown status
7
154-
155 return
executed 234 times by 2 tests: return true;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
true;
executed 234 times by 2 tests: return true;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
234
156}-
157-
158-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9