OpenCoverage

qnetworkcookie.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/access/qnetworkcookie.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtNetwork module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qnetworkcookie.h"-
41#include "qnetworkcookie_p.h"-
42-
43#include "qnetworkrequest.h"-
44#include "qnetworkreply.h"-
45#include "QtCore/qbytearray.h"-
46#include "QtCore/qdebug.h"-
47#include "QtCore/qlist.h"-
48#include "QtCore/qlocale.h"-
49#include "QtCore/qstring.h"-
50#include "QtCore/qstringlist.h"-
51#include "QtCore/qurl.h"-
52#include "QtNetwork/qhostaddress.h"-
53#include "private/qobject_p.h"-
54-
55QT_BEGIN_NAMESPACE-
56-
57/*!-
58 \class QNetworkCookie-
59 \since 4.4-
60 \ingroup shared-
61 \inmodule QtNetwork-
62-
63 \brief The QNetworkCookie class holds one network cookie.-
64-
65 Cookies are small bits of information that stateless protocols-
66 like HTTP use to maintain some persistent information across-
67 requests.-
68-
69 A cookie is set by a remote server when it replies to a request-
70 and it expects the same cookie to be sent back when further-
71 requests are sent.-
72-
73 QNetworkCookie holds one such cookie as received from the-
74 network. A cookie has a name and a value, but those are opaque to-
75 the application (that is, the information stored in them has no-
76 meaning to the application). A cookie has an associated path name-
77 and domain, which indicate when the cookie should be sent again to-
78 the server.-
79-
80 A cookie can also have an expiration date, indicating its-
81 validity. If the expiration date is not present, the cookie is-
82 considered a "session cookie" and should be discarded when the-
83 application exits (or when its concept of session is over).-
84-
85 QNetworkCookie provides a way of parsing a cookie from the HTTP-
86 header format using the QNetworkCookie::parseCookies()-
87 function. However, when received in a QNetworkReply, the cookie is-
88 already parsed.-
89-
90 This class implements cookies as described by the-
91 \l{Netscape Cookie Specification}{initial cookie specification by-
92 Netscape}, which is somewhat similar to the \l{http://www.rfc-editor.org/rfc/rfc2109.txt}{RFC 2109} specification,-
93 plus the \l{Mitigating Cross-site Scripting With HTTP-only Cookies}-
94 {"HttpOnly" extension}. The more recent \l{http://www.rfc-editor.org/rfc/rfc2965.txt}{RFC 2965} specification-
95 (which uses the Set-Cookie2 header) is not supported.-
96-
97 \sa QNetworkCookieJar, QNetworkRequest, QNetworkReply-
98*/-
99-
100/*!-
101 Create a new QNetworkCookie object, initializing the cookie name-
102 to \a name and its value to \a value.-
103-
104 A cookie is only valid if it has a name. However, the value is-
105 opaque to the application and being empty may have significance to-
106 the remote server.-
107*/-
108QNetworkCookie::QNetworkCookie(const QByteArray &name, const QByteArray &value)-
109 : d(new QNetworkCookiePrivate)-
110{-
111 qRegisterMetaType<QNetworkCookie>();-
112 qRegisterMetaType<QList<QNetworkCookie> >();-
113-
114 d->name = name;-
115 d->value = value;-
116}
executed 919 times by 5 tests: end of block
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
919
117-
118/*!-
119 Creates a new QNetworkCookie object by copying the contents of \a-
120 other.-
121*/-
122QNetworkCookie::QNetworkCookie(const QNetworkCookie &other)-
123 : d(other.d)-
124{-
125}
executed 2224 times by 5 tests: end of block
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
2224
126-
127/*!-
128 Destroys this QNetworkCookie object.-
129*/-
130QNetworkCookie::~QNetworkCookie()-
131{-
132 // QSharedDataPointer auto deletes-
133 d = 0;-
134}
executed 3143 times by 5 tests: end of block
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
3143
135-
136/*!-
137 Copies the contents of the QNetworkCookie object \a other to this-
138 object.-
139*/-
140QNetworkCookie &QNetworkCookie::operator=(const QNetworkCookie &other)-
141{-
142 d = other.d;-
143 return *this;
executed 2 times by 1 test: return *this;
Executed by:
  • tst_qnetworkcookiejar - unknown status
2
144}-
145-
146/*!-
147 \fn void QNetworkCookie::swap(QNetworkCookie &other)-
148 \since 5.0-
149-
150 Swaps this cookie with \a other. This function is very fast and-
151 never fails.-
152*/-
153-
154/*!-
155 \fn bool QNetworkCookie::operator!=(const QNetworkCookie &other) const-
156-
157 Returns \c true if this cookie is not equal to \a other.-
158-
159 \sa operator==()-
160*/-
161-
162/*!-
163 \since 5.0-
164 Returns \c true if this cookie is equal to \a other. This function-
165 only returns \c true if all fields of the cookie are the same.-
166-
167 However, in some contexts, two cookies of the same name could be-
168 considered equal.-
169-
170 \sa operator!=(), hasSameIdentifier()-
171*/-
172bool QNetworkCookie::operator==(const QNetworkCookie &other) const-
173{-
174 if (d == other.d)
d == other.dDescription
TRUEevaluated 33 times by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 499 times by 4 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
33-499
175 return true;
executed 33 times by 1 test: return true;
Executed by:
  • tst_qnetworkcookiejar - unknown status
33
176 return d->name == other.d->name &&
executed 499 times by 4 tests: return d->name == other.d->name && d->value == other.d->value && d->expirationDate.toUTC() == other.d->expirationDate.toUTC() && d->domain == other.d->domain && d->path == other.d->path && d->secure == other.d->secure && d->comment == other.d->comment;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
499
177 d->value == other.d->value &&
executed 499 times by 4 tests: return d->name == other.d->name && d->value == other.d->value && d->expirationDate.toUTC() == other.d->expirationDate.toUTC() && d->domain == other.d->domain && d->path == other.d->path && d->secure == other.d->secure && d->comment == other.d->comment;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
499
178 d->expirationDate.toUTC() == other.d->expirationDate.toUTC() &&
executed 499 times by 4 tests: return d->name == other.d->name && d->value == other.d->value && d->expirationDate.toUTC() == other.d->expirationDate.toUTC() && d->domain == other.d->domain && d->path == other.d->path && d->secure == other.d->secure && d->comment == other.d->comment;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
499
179 d->domain == other.d->domain &&
executed 499 times by 4 tests: return d->name == other.d->name && d->value == other.d->value && d->expirationDate.toUTC() == other.d->expirationDate.toUTC() && d->domain == other.d->domain && d->path == other.d->path && d->secure == other.d->secure && d->comment == other.d->comment;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
499
180 d->path == other.d->path &&
executed 499 times by 4 tests: return d->name == other.d->name && d->value == other.d->value && d->expirationDate.toUTC() == other.d->expirationDate.toUTC() && d->domain == other.d->domain && d->path == other.d->path && d->secure == other.d->secure && d->comment == other.d->comment;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
499
181 d->secure == other.d->secure &&
executed 499 times by 4 tests: return d->name == other.d->name && d->value == other.d->value && d->expirationDate.toUTC() == other.d->expirationDate.toUTC() && d->domain == other.d->domain && d->path == other.d->path && d->secure == other.d->secure && d->comment == other.d->comment;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
499
182 d->comment == other.d->comment;
executed 499 times by 4 tests: return d->name == other.d->name && d->value == other.d->value && d->expirationDate.toUTC() == other.d->expirationDate.toUTC() && d->domain == other.d->domain && d->path == other.d->path && d->secure == other.d->secure && d->comment == other.d->comment;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
499
183}-
184-
185/*!-
186 Returns \c true if this cookie has the same identifier tuple as \a other.-
187 The identifier tuple is composed of the name, domain and path.-
188-
189 \sa operator==()-
190*/-
191bool QNetworkCookie::hasSameIdentifier(const QNetworkCookie &other) const-
192{-
193 return d->name == other.d->name && d->domain == other.d->domain && d->path == other.d->path;
executed 45 times by 2 tests: return d->name == other.d->name && d->domain == other.d->domain && d->path == other.d->path;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
45
194}-
195-
196/*!-
197 Returns \c true if the "secure" option was specified in the cookie-
198 string, false otherwise.-
199-
200 Secure cookies may contain private information and should not be-
201 resent over unencrypted connections.-
202-
203 \sa setSecure()-
204*/-
205bool QNetworkCookie::isSecure() const-
206{-
207 return d->secure;
executed 1312 times by 4 tests: return d->secure;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
1312
208}-
209-
210/*!-
211 Sets the secure flag of this cookie to \a enable.-
212-
213 Secure cookies may contain private information and should not be-
214 resent over unencrypted connections.-
215-
216 \sa isSecure()-
217*/-
218void QNetworkCookie::setSecure(bool enable)-
219{-
220 d->secure = enable;-
221}
executed 44 times by 2 tests: end of block
Executed by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
44
222-
223/*!-
224 \since 4.5-
225-
226 Returns \c true if the "HttpOnly" flag is enabled for this cookie.-
227-
228 A cookie that is "HttpOnly" is only set and retrieved by the-
229 network requests and replies; i.e., the HTTP protocol. It is not-
230 accessible from scripts running on browsers.-
231-
232 \sa isSecure()-
233*/-
234bool QNetworkCookie::isHttpOnly() const-
235{-
236 return d->httpOnly;
executed 1106 times by 4 tests: return d->httpOnly;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
1106
237}-
238-
239/*!-
240 \since 4.5-
241-
242 Sets this cookie's "HttpOnly" flag to \a enable.-
243*/-
244void QNetworkCookie::setHttpOnly(bool enable)-
245{-
246 d->httpOnly = enable;-
247}
executed 19 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
19
248-
249/*!-
250 Returns \c true if this cookie is a session cookie. A session cookie-
251 is a cookie which has no expiration date, which means it should be-
252 discarded when the application's concept of session is over-
253 (usually, when the application exits).-
254-
255 \sa expirationDate(), setExpirationDate()-
256*/-
257bool QNetworkCookie::isSessionCookie() const-
258{-
259 return !d->expirationDate.isValid();
executed 1546 times by 4 tests: return !d->expirationDate.isValid();
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
1546
260}-
261-
262/*!-
263 Returns the expiration date for this cookie. If this cookie is a-
264 session cookie, the QDateTime returned will not be valid. If the-
265 date is in the past, this cookie has already expired and should-
266 not be sent again back to a remote server.-
267-
268 The expiration date corresponds to the parameters of the "expires"-
269 entry in the cookie string.-
270-
271 \sa isSessionCookie(), setExpirationDate()-
272*/-
273QDateTime QNetworkCookie::expirationDate() const-
274{-
275 return d->expirationDate;
executed 252 times by 3 tests: return d->expirationDate;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
252
276}-
277-
278/*!-
279 Sets the expiration date of this cookie to \a date. Setting an-
280 invalid expiration date to this cookie will mean it's a session-
281 cookie.-
282-
283 \sa isSessionCookie(), expirationDate()-
284*/-
285void QNetworkCookie::setExpirationDate(const QDateTime &date)-
286{-
287 d->expirationDate = date;-
288}
executed 507 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
507
289-
290/*!-
291 Returns the domain this cookie is associated with. This-
292 corresponds to the "domain" field of the cookie string.-
293-
294 Note that the domain here may start with a dot, which is not a-
295 valid hostname. However, it means this cookie matches all-
296 hostnames ending with that domain name.-
297-
298 \sa setDomain()-
299*/-
300QString QNetworkCookie::domain() const-
301{-
302 return d->domain;
executed 528 times by 3 tests: return d->domain;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
528
303}-
304-
305/*!-
306 Sets the domain associated with this cookie to be \a domain.-
307-
308 \sa domain()-
309*/-
310void QNetworkCookie::setDomain(const QString &domain)-
311{-
312 d->domain = domain;-
313}
executed 157 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
157
314-
315/*!-
316 Returns the path associated with this cookie. This corresponds to-
317 the "path" field of the cookie string.-
318-
319 \sa setPath()-
320*/-
321QString QNetworkCookie::path() const-
322{-
323 return d->path;
executed 308 times by 3 tests: return d->path;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
308
324}-
325-
326/*!-
327 Sets the path associated with this cookie to be \a path.-
328-
329 \sa path()-
330*/-
331void QNetworkCookie::setPath(const QString &path)-
332{-
333 d->path = path;-
334}
executed 197 times by 4 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
197
335-
336/*!-
337 Returns the name of this cookie. The only mandatory field of a-
338 cookie is its name, without which it is not considered valid.-
339-
340 \sa setName(), value()-
341*/-
342QByteArray QNetworkCookie::name() const-
343{-
344 return d->name;
executed 979 times by 5 tests: return d->name;
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
979
345}-
346-
347/*!-
348 Sets the name of this cookie to be \a cookieName. Note that-
349 setting a cookie name to an empty QByteArray will make this cookie-
350 invalid.-
351-
352 \sa name(), value()-
353*/-
354void QNetworkCookie::setName(const QByteArray &cookieName)-
355{-
356 d->name = cookieName;-
357}
executed 858 times by 5 tests: end of block
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
858
358-
359/*!-
360 Returns this cookies value, as specified in the cookie-
361 string. Note that a cookie is still valid if its value is empty.-
362-
363 Cookie name-value pairs are considered opaque to the application:-
364 that is, their values don't mean anything.-
365-
366 \sa setValue(), name()-
367*/-
368QByteArray QNetworkCookie::value() const-
369{-
370 return d->value;
executed 305 times by 2 tests: return d->value;
Executed by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
305
371}-
372-
373/*!-
374 Sets the value of this cookie to be \a value.-
375-
376 \sa value(), name()-
377*/-
378void QNetworkCookie::setValue(const QByteArray &value)-
379{-
380 d->value = value;-
381}
executed 866 times by 5 tests: end of block
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
866
382-
383// ### move this to qnetworkcookie_p.h and share with qnetworkaccesshttpbackend-
384static QPair<QByteArray, QByteArray> nextField(const QByteArray &text, int &position, bool isNameValue)-
385{-
386 // format is one of:-
387 // (1) token-
388 // (2) token = token-
389 // (3) token = quoted-string-
390 const int length = text.length();-
391 position = nextNonWhitespace(text, position);-
392-
393 int semiColonPosition = text.indexOf(';', position);-
394 if (semiColonPosition < 0)
semiColonPosition < 0Description
TRUEevaluated 717 times by 5 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
FALSEevaluated 694 times by 4 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
694-717
395 semiColonPosition = length; //no ';' means take everything to end of string
executed 717 times by 5 tests: semiColonPosition = length;
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
717
396-
397 int equalsPosition = text.indexOf('=', position);-
398 if (equalsPosition < 0 || equalsPosition > semiColonPosition) {
equalsPosition < 0Description
TRUEevaluated 125 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 1286 times by 5 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
equalsPosition...iColonPositionDescription
TRUEevaluated 20 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 1266 times by 5 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
20-1286
399 if (isNameValue)
isNameValueDescription
TRUEevaluated 34 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 111 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
34-111
400 return qMakePair(QByteArray(), QByteArray()); //'=' is required for name-value-pair (RFC6265 section 5.2, rule 2)
executed 34 times by 2 tests: return qMakePair(QByteArray(), QByteArray());
Executed by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
34
401 equalsPosition = semiColonPosition; //no '=' means there is an attribute-name but no attribute-value-
402 }
executed 111 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
111
403-
404 QByteArray first = text.mid(position, equalsPosition - position).trimmed();-
405 QByteArray second;-
406 int secondLength = semiColonPosition - equalsPosition - 1;-
407 if (secondLength > 0)
secondLength > 0Description
TRUEevaluated 1237 times by 5 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
FALSEevaluated 140 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
140-1237
408 second = text.mid(equalsPosition + 1, secondLength).trimmed();
executed 1237 times by 5 tests: second = text.mid(equalsPosition + 1, secondLength).trimmed();
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
1237
409-
410 position = semiColonPosition;-
411 return qMakePair(first, second);
executed 1377 times by 5 tests: return qMakePair(first, second);
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
1377
412}-
413-
414/*!-
415 \enum QNetworkCookie::RawForm-
416-
417 This enum is used with the toRawForm() function to declare which-
418 form of a cookie shall be returned.-
419-
420 \value NameAndValueOnly makes toRawForm() return only the-
421 "NAME=VALUE" part of the cookie, as suitable for sending back-
422 to a server in a client request's "Cookie:" header. Multiple-
423 cookies are separated by a semi-colon in the "Cookie:" header-
424 field.-
425-
426 \value Full makes toRawForm() return the full-
427 cookie contents, as suitable for sending to a client in a-
428 server's "Set-Cookie:" header.-
429-
430 Note that only the Full form of the cookie can be parsed back into-
431 its original contents.-
432-
433 \sa toRawForm(), parseCookies()-
434*/-
435-
436/*!-
437 Returns the raw form of this QNetworkCookie. The QByteArray-
438 returned by this function is suitable for an HTTP header, either-
439 in a server response (the Set-Cookie header) or the client request-
440 (the Cookie header). You can choose from one of two formats, using-
441 \a form.-
442-
443 \sa parseCookies()-
444*/-
445QByteArray QNetworkCookie::toRawForm(RawForm form) const-
446{-
447 QByteArray result;-
448 if (d->name.isEmpty())
d->name.isEmpty()Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 1120 times by 4 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
6-1120
449 return result; // not a valid cookie
executed 6 times by 1 test: return result;
Executed by:
  • tst_qnetworkcookie - unknown status
6
450-
451 result = d->name;-
452 result += '=';-
453 result += d->value;-
454-
455 if (form == Full) {
form == FullDescription
TRUEevaluated 1106 times by 4 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
FALSEevaluated 14 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkrequest - unknown status
14-1106
456 // same as above, but encoding everything back-
457 if (isSecure())
isSecure()Description
TRUEevaluated 60 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 1046 times by 4 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
60-1046
458 result += "; secure";
executed 60 times by 1 test: result += "; secure";
Executed by:
  • tst_qnetworkcookie - unknown status
60
459 if (isHttpOnly())
isHttpOnly()Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 1066 times by 4 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
40-1066
460 result += "; HttpOnly";
executed 40 times by 1 test: result += "; HttpOnly";
Executed by:
  • tst_qnetworkcookie - unknown status
40
461 if (!isSessionCookie()) {
!isSessionCookie()Description
TRUEevaluated 605 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 501 times by 4 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
501-605
462 result += "; expires=";-
463 result += QLocale::c().toString(d->expirationDate.toUTC(),-
464 QLatin1String("ddd, dd-MMM-yyyy hh:mm:ss 'GMT")).toLatin1();-
465 }
executed 605 times by 1 test: end of block
Executed by:
  • tst_qnetworkcookie - unknown status
605
466 if (!d->domain.isEmpty()) {
!d->domain.isEmpty()Description
TRUEevaluated 172 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 934 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkrequest - unknown status
172-934
467 result += "; domain=";-
468 if (d->domain.startsWith(QLatin1Char('.'))) {
d->domain.star...tin1Char('.'))Description
TRUEevaluated 122 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 50 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
50-122
469 result += '.';-
470 result += QUrl::toAce(d->domain.mid(1));-
471 } else {
executed 122 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
122
472 QHostAddress hostAddr(d->domain);-
473 if (hostAddr.protocol() == QAbstractSocket::IPv6Protocol) {
hostAddr.proto...::IPv6ProtocolDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 49 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
1-49
474 result += '[';-
475 result += d->domain.toUtf8();-
476 result += ']';-
477 } else {
executed 1 time by 1 test: end of block
Executed by:
  • tst_qnetworkcookiejar - unknown status
1
478 result += QUrl::toAce(d->domain);-
479 }
executed 49 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
49
480 }-
481 }-
482 if (!d->path.isEmpty()) {
!d->path.isEmpty()Description
TRUEevaluated 219 times by 4 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
FALSEevaluated 887 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkrequest - unknown status
219-887
483 result += "; path=";-
484 result += d->path.toUtf8();-
485 }
executed 219 times by 4 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
219
486 }
executed 1106 times by 4 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
1106
487 return result;
executed 1120 times by 4 tests: return result;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
1120
488}-
489-
490static const char zones[] =-
491 "pst\0" // -8-
492 "pdt\0"-
493 "mst\0" // -7-
494 "mdt\0"-
495 "cst\0" // -6-
496 "cdt\0"-
497 "est\0" // -5-
498 "edt\0"-
499 "ast\0" // -4-
500 "nst\0" // -3-
501 "gmt\0" // 0-
502 "utc\0"-
503 "bst\0"-
504 "met\0" // 1-
505 "eet\0" // 2-
506 "jst\0" // 9-
507 "\0";-
508static const int zoneOffsets[] = {-8, -8, -7, -7, -6, -6, -5, -5, -4, -3, 0, 0, 0, 1, 2, 9 };-
509-
510static const char months[] =-
511 "jan\0"-
512 "feb\0"-
513 "mar\0"-
514 "apr\0"-
515 "may\0"-
516 "jun\0"-
517 "jul\0"-
518 "aug\0"-
519 "sep\0"-
520 "oct\0"-
521 "nov\0"-
522 "dec\0"-
523 "\0";-
524-
525static inline bool isNumber(char s)-
526{
executed 4731 times by 3 tests: return s >= '0' && s <= '9';
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
return s >= '0' && s <= '9'; }
executed 4731 times by 3 tests: return s >= '0' && s <= '9';
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
4731
527-
528static inline bool isTerminator(char c)-
529{
executed 6332 times by 3 tests: return c == '\n' || c == '\r';
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
return c == '\n' || c == '\r'; }
executed 6332 times by 3 tests: return c == '\n' || c == '\r';
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
6332
530-
531static inline bool isValueSeparator(char c)-
532{
executed 6332 times by 3 tests: return isTerminator(c) || c == ';';
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
return isTerminator(c) || c == ';'; }
executed 6332 times by 3 tests: return isTerminator(c) || c == ';';
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
6332
533-
534static inline bool isWhitespace(char c)-
535{
executed 315 times by 3 tests: return c == ' ' || c == '\t';
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
return c == ' ' || c == '\t'; }
executed 315 times by 3 tests: return c == ' ' || c == '\t';
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
315
536-
537static bool checkStaticArray(int &val, const QByteArray &dateString, int at, const char *array, int size)-
538{-
539 if (dateString[at] < 'a' || dateString[at] > 'z')
dateString[at] < 'a'Description
TRUEevaluated 2637 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 1800 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
dateString[at] > 'z'Description
TRUEnever evaluated
FALSEevaluated 1800 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
0-2637
540 return false;
executed 2637 times by 3 tests: return false;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
2637
541 if (val == -1 && dateString.length() >= at + 3) {
val == -1Description
TRUEevaluated 1581 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 219 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
dateString.length() >= at + 3Description
TRUEevaluated 1571 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 10 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
10-1581
542 int j = 0;-
543 int i = 0;-
544 while (i <= size) {
i <= sizeDescription
TRUEevaluated 21501 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 1156 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
1156-21501
545 const char *str = array + i;-
546 if (str[0] == dateString[at]
str[0] == dateString[at]Description
TRUEevaluated 1149 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 20352 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
1149-20352
547 && str[1] == dateString[at + 1]
str[1] == dateString[at + 1]Description
TRUEevaluated 460 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 689 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
460-689
548 && str[2] == dateString[at + 2]) {
str[2] == dateString[at + 2]Description
TRUEevaluated 415 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 45 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
45-415
549 val = j;-
550 return true;
executed 415 times by 3 tests: return true;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
415
551 }-
552 i += int(strlen(str)) + 1;-
553 ++j;-
554 }
executed 21086 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
21086
555 }
executed 1156 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
1156
556 return false;
executed 1385 times by 3 tests: return false;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
1385
557}-
558-
559//#define PARSEDATESTRINGDEBUG-
560-
561#define ADAY 1-
562#define AMONTH 2-
563#define AYEAR 4-
564-
565/*-
566 Parse all the date formats that Firefox can.-
567-
568 The official format is:-
569 expires=ddd(d)?, dd-MMM-yyyy hh:mm:ss GMT-
570-
571 But browsers have been supporting a very wide range of date-
572 strings. To work on many sites we need to support more then-
573 just the official date format.-
574-
575 For reference see Firefox's PR_ParseTimeStringToExplodedTime in-
576 prtime.c. The Firefox date parser is coded in a very complex way-
577 and is slightly over ~700 lines long. While this implementation-
578 will be slightly slower for the non standard dates it is smaller,-
579 more readable, and maintainable.-
580-
581 Or in their own words:-
582 "} // else what the hell is this."-
583*/-
584static QDateTime parseDateString(const QByteArray &dateString)-
585{-
586 QTime time;-
587 // placeholders for values when we are not sure it is a year, month or day-
588 int unknown[3] = {-1, -1, -1};-
589 int month = -1;-
590 int day = -1;-
591 int year = -1;-
592 int zoneOffset = -1;-
593-
594 // hour:minute:second.ms pm-
595 QRegExp timeRx(QLatin1String("(\\d{1,2}):(\\d{1,2})(:(\\d{1,2})|)(\\.(\\d{1,3})|)((\\s{0,}(am|pm))|)"));-
596-
597 int at = 0;-
598 while (at < dateString.length()) {
at < dateString.length()Description
TRUEevaluated 3176 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 267 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
267-3176
599#ifdef PARSEDATESTRINGDEBUG-
600 qDebug() << dateString.mid(at);-
601#endif-
602 bool isNum = isNumber(dateString[at]);-
603-
604 // Month-
605 if (!isNum
!isNumDescription
TRUEevaluated 2354 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 822 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
822-2354
606 && checkStaticArray(month, dateString, at, months, sizeof(months)- 1)) {
checkStaticArr...of(months)- 1)Description
TRUEevaluated 229 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 2125 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
229-2125
607 ++month;-
608#ifdef PARSEDATESTRINGDEBUG-
609 qDebug() << "Month:" << month;-
610#endif-
611 at += 3;-
612 continue;
executed 229 times by 3 tests: continue;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
229
613 }-
614 // Zone-
615 if (!isNum
!isNumDescription
TRUEevaluated 2125 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 822 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
822-2125
616 && zoneOffset == -1
zoneOffset == -1Description
TRUEevaluated 2083 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 42 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
42-2083
617 && checkStaticArray(zoneOffset, dateString, at, zones, sizeof(zones)- 1)) {
checkStaticArr...eof(zones)- 1)Description
TRUEevaluated 186 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 1897 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
186-1897
618 int sign = (at >= 0 && dateString[at - 1] == '-') ? -1 : 1;
at >= 0Description
TRUEevaluated 186 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEnever evaluated
dateString[at - 1] == '-'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 185 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
0-186
619 zoneOffset = sign * zoneOffsets[zoneOffset] * 60 * 60;-
620#ifdef PARSEDATESTRINGDEBUG-
621 qDebug() << "Zone:" << month;-
622#endif-
623 at += 3;-
624 continue;
executed 186 times by 3 tests: continue;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
186
625 }-
626 // Zone offset-
627 if (!isNum
!isNumDescription
TRUEevaluated 1939 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 822 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
822-1939
628 && (zoneOffset == -1 || zoneOffset == 0) // Can only go after gmt
zoneOffset == -1Description
TRUEevaluated 1897 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 42 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
zoneOffset == 0Description
TRUEevaluated 27 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 15 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
15-1897
629 && (dateString[at] == '+' || dateString[at] == '-')
dateString[at] == '+'Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 1915 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
dateString[at] == '-'Description
TRUEevaluated 306 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 1609 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
9-1915
630 && (at == 0
at == 0Description
TRUEnever evaluated
FALSEevaluated 315 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
0-315
631 || isWhitespace(dateString[at - 1])
isWhitespace(d...tring[at - 1])Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 308 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
7-308
632 || dateString[at - 1] == ','
dateString[at - 1] == ','Description
TRUEnever evaluated
FALSEevaluated 308 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
0-308
633 || (at >= 3
at >= 3Description
TRUEevaluated 301 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
7-301
634 && (dateString[at - 3] == 'g')
(dateString[at - 3] == 'g')Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 296 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
5-296
635 && (dateString[at - 2] == 'm')
(dateString[at - 2] == 'm')Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEnever evaluated
0-5
636 && (dateString[at - 1] == 't')))) {
(dateString[at - 1] == 't')Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEnever evaluated
0-5
637-
638 int end = 1;-
639 while (end < 5 && dateString.length() > at+end
end < 5Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 5 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
dateString.length() > at+endDescription
TRUEevaluated 31 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
5-38
640 && dateString[at + end] >= '0' && dateString[at + end] <= '9')
dateString[at + end] >= '0'Description
TRUEevaluated 31 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEnever evaluated
dateString[at + end] <= '9'Description
TRUEevaluated 31 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEnever evaluated
0-31
641 ++end;
executed 31 times by 1 test: ++end;
Executed by:
  • tst_qnetworkcookie - unknown status
31
642 int minutes = 0;-
643 int hours = 0;-
644 switch (end - 1) {-
645 case 4:
executed 5 times by 1 test: case 4:
Executed by:
  • tst_qnetworkcookie - unknown status
5
646 minutes = atoi(dateString.mid(at + 3, 2).constData());-
647 // fall through-
648 case 2:
code before this statement executed 5 times by 1 test: case 2:
Executed by:
  • tst_qnetworkcookie - unknown status
executed 2 times by 1 test: case 2:
Executed by:
  • tst_qnetworkcookie - unknown status
2-5
649 hours = atoi(dateString.mid(at + 1, 2).constData());-
650 break;
executed 7 times by 1 test: break;
Executed by:
  • tst_qnetworkcookie - unknown status
7
651 case 1:
executed 4 times by 1 test: case 1:
Executed by:
  • tst_qnetworkcookie - unknown status
4
652 hours = atoi(dateString.mid(at + 1, 1).constData());-
653 break;
executed 4 times by 1 test: break;
Executed by:
  • tst_qnetworkcookie - unknown status
4
654 default:
executed 1 time by 1 test: default:
Executed by:
  • tst_qnetworkcookie - unknown status
1
655 at += end;-
656 continue;
executed 1 time by 1 test: continue;
Executed by:
  • tst_qnetworkcookie - unknown status
1
657 }-
658 if (end != 1) {
end != 1Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEnever evaluated
0-11
659 int sign = dateString[at] == '-' ? -1 : 1;
dateString[at] == '-'Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
3-8
660 zoneOffset = sign * ((minutes * 60) + (hours * 60 * 60));-
661#ifdef PARSEDATESTRINGDEBUG-
662 qDebug() << "Zone offset:" << zoneOffset << hours << minutes;-
663#endif-
664 at += end;-
665 continue;
executed 11 times by 1 test: continue;
Executed by:
  • tst_qnetworkcookie - unknown status
11
666 }-
667 }
never executed: end of block
0
668-
669 // Time-
670 if (isNum && time.isNull()
isNumDescription
TRUEevaluated 822 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 1927 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
time.isNull()Description
TRUEevaluated 805 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 17 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
17-1927
671 && dateString.length() >= at + 3
dateString.length() >= at + 3Description
TRUEevaluated 804 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
1-804
672 && (dateString[at + 2] == ':' || dateString[at + 1] == ':')) {
dateString[at + 2] == ':'Description
TRUEevaluated 184 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 620 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
dateString[at + 1] == ':'Description
TRUEevaluated 78 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 542 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
78-620
673 // While the date can be found all over the string the format-
674 // for the time is set and a nice regexp can be used.-
675 int pos = timeRx.indexIn(QLatin1String(dateString), at);-
676 if (pos != -1) {
pos != -1Description
TRUEevaluated 262 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEnever evaluated
0-262
677 QStringList list = timeRx.capturedTexts();-
678 int h = atoi(list.at(1).toLatin1().constData());-
679 int m = atoi(list.at(2).toLatin1().constData());-
680 int s = atoi(list.at(4).toLatin1().constData());-
681 int ms = atoi(list.at(6).toLatin1().constData());-
682 if (h < 12 && !list.at(9).isEmpty())
h < 12Description
TRUEevaluated 199 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 63 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
!list.at(9).isEmpty()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 191 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
8-199
683 if (list.at(9) == QLatin1String("pm"))
list.at(9) == ...n1String("pm")Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
2-6
684 h += 12;
executed 6 times by 1 test: h += 12;
Executed by:
  • tst_qnetworkcookie - unknown status
6
685 time = QTime(h, m, s, ms);-
686#ifdef PARSEDATESTRINGDEBUG-
687 qDebug() << "Time:" << list << timeRx.matchedLength();-
688#endif-
689 at += timeRx.matchedLength();-
690 continue;
executed 262 times by 3 tests: continue;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
262
691 }-
692 }
never executed: end of block
0
693-
694 // 4 digit Year-
695 if (isNum
isNumDescription
TRUEevaluated 560 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 1927 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
560-1927
696 && year == -1
year == -1Description
TRUEevaluated 538 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
22-538
697 && dateString.length() > at + 3) {
dateString.length() > at + 3Description
TRUEevaluated 534 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
4-534
698 if (isNumber(dateString[at + 1])
isNumber(dateString[at + 1])Description
TRUEevaluated 463 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 71 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
71-463
699 && isNumber(dateString[at + 2])
isNumber(dateString[at + 2])Description
TRUEevaluated 166 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 297 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
166-297
700 && isNumber(dateString[at + 3])) {
isNumber(dateString[at + 3])Description
TRUEevaluated 166 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEnever evaluated
0-166
701 year = atoi(dateString.mid(at, 4).constData());-
702 at += 4;-
703#ifdef PARSEDATESTRINGDEBUG-
704 qDebug() << "Year:" << year;-
705#endif-
706 continue;
executed 166 times by 2 tests: continue;
Executed by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
166
707 }-
708 }
executed 368 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
368
709-
710 // a one or two digit number-
711 // Could be month, day or year-
712 if (isNum) {
isNumDescription
TRUEevaluated 394 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 1927 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
394-1927
713 int length = 1;-
714 if (dateString.length() > at + 1
dateString.length() > at + 1Description
TRUEevaluated 392 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
2-392
715 && isNumber(dateString[at + 1]))
isNumber(dateString[at + 1])Description
TRUEevaluated 314 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 78 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
78-314
716 ++length;
executed 314 times by 3 tests: ++length;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
314
717 int x = atoi(dateString.mid(at, length).constData());-
718 if (year == -1 && (x > 31 || x == 0)) {
year == -1Description
TRUEevaluated 372 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 22 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
x > 31Description
TRUEevaluated 70 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 302 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
x == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 300 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
2-372
719 year = x;-
720 } else {
executed 72 times by 1 test: end of block
Executed by:
  • tst_qnetworkcookie - unknown status
72
721 if (unknown[0] == -1) unknown[0] = x;
executed 263 times by 3 tests: unknown[0] = x;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
unknown[0] == -1Description
TRUEevaluated 263 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 59 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
59-263
722 else if (unknown[1] == -1) unknown[1] = x;
executed 41 times by 2 tests: unknown[1] = x;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
unknown[1] == -1Description
TRUEevaluated 41 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
18-41
723 else if (unknown[2] == -1) unknown[2] = x;
executed 18 times by 1 test: unknown[2] = x;
Executed by:
  • tst_qnetworkcookie - unknown status
unknown[2] == -1Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEnever evaluated
0-18
724 }
executed 322 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
322
725 at += length;-
726#ifdef PARSEDATESTRINGDEBUG-
727 qDebug() << "Saving" << x;-
728#endif-
729 continue;
executed 394 times by 3 tests: continue;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
394
730 }-
731-
732 // Unknown character, typically a weekday such as 'Mon'-
733 ++at;-
734 }
executed 1927 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
1927
735-
736 // Once we are done parsing the string take the digits in unknown-
737 // and determine which is the unknown year/month/day-
738-
739 int couldBe[3] = { 0, 0, 0 };-
740 int unknownCount = 3;-
741 for (int i = 0; i < unknownCount; ++i) {
i < unknownCountDescription
TRUEevaluated 571 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 267 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
267-571
742 if (unknown[i] == -1) {
unknown[i] == -1Description
TRUEevaluated 249 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 322 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
249-322
743 couldBe[i] = ADAY | AYEAR | AMONTH;-
744 unknownCount = i;-
745 continue;
executed 249 times by 3 tests: continue;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
249
746 }-
747-
748 if (unknown[i] >= 1)
unknown[i] >= 1Description
TRUEevaluated 322 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEnever evaluated
0-322
749 couldBe[i] = ADAY;
executed 322 times by 3 tests: couldBe[i] = 1;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
322
750-
751 if (month == -1 && unknown[i] >= 1 && unknown[i] <= 12)
month == -1Description
TRUEevaluated 86 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 236 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
unknown[i] >= 1Description
TRUEevaluated 86 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEnever evaluated
unknown[i] <= 12Description
TRUEevaluated 52 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 34 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
0-236
752 couldBe[i] |= AMONTH;
executed 52 times by 1 test: couldBe[i] |= 2;
Executed by:
  • tst_qnetworkcookie - unknown status
52
753-
754 if (year == -1)
year == -1Description
TRUEevaluated 68 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
FALSEevaluated 254 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
68-254
755 couldBe[i] |= AYEAR;
executed 68 times by 2 tests: couldBe[i] |= 4;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
68
756 }
executed 322 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
322
757-
758 // For any possible day make sure one of the values that could be a month-
759 // can contain that day.-
760 // For any possible month make sure one of the values that can be a-
761 // day that month can have.-
762 // Example: 31 11 06-
763 // 31 can't be a day because 11 and 6 don't have 31 days-
764 for (int i = 0; i < unknownCount; ++i) {
i < unknownCountDescription
TRUEevaluated 322 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 267 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
267-322
765 int currentValue = unknown[i];-
766 bool findMatchingMonth = couldBe[i] & ADAY && currentValue >= 29;
couldBe[i] & 1Description
TRUEevaluated 322 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEnever evaluated
currentValue >= 29Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 296 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
0-322
767 bool findMatchingDay = couldBe[i] & AMONTH;-
768 if (!findMatchingMonth || !findMatchingDay)
!findMatchingMonthDescription
TRUEevaluated 296 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 26 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
!findMatchingDayDescription
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEnever evaluated
0-296
769 continue;
executed 322 times by 3 tests: continue;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
322
770 for (int j = 0; j < 3; ++j) {
j < 3Description
TRUEnever evaluated
FALSEnever evaluated
0
771 if (j == i)
j == iDescription
TRUEnever evaluated
FALSEnever evaluated
0
772 continue;
never executed: continue;
0
773 for (int k = 0; k < 2; ++k) {
k < 2Description
TRUEnever evaluated
FALSEnever evaluated
0
774 if (k == 0 && !(findMatchingMonth && (couldBe[j] & AMONTH)))
k == 0Description
TRUEnever evaluated
FALSEnever evaluated
findMatchingMonthDescription
TRUEnever evaluated
FALSEnever evaluated
(couldBe[j] & 2)Description
TRUEnever evaluated
FALSEnever evaluated
0
775 continue;
never executed: continue;
0
776 else if (k == 1 && !(findMatchingDay && (couldBe[j] & ADAY)))
k == 1Description
TRUEnever evaluated
FALSEnever evaluated
findMatchingDayDescription
TRUEnever evaluated
FALSEnever evaluated
(couldBe[j] & 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
777 continue;
never executed: continue;
0
778 int m = currentValue;-
779 int d = unknown[j];-
780 if (k == 0)
k == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
781 qSwap(m, d);
never executed: qSwap(m, d);
0
782 if (m == -1) m = month;
never executed: m = month;
m == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
783 bool found = true;-
784 switch(m) {-
785 case 2:
never executed: case 2:
0
786 // When we get 29 and the year ends up having only 28-
787 // See date.isValid below-
788 // Example: 29 23 Feb-
789 if (d <= 29)
d <= 29Description
TRUEnever evaluated
FALSEnever evaluated
0
790 found = false;
never executed: found = false;
0
791 break;
never executed: break;
0
792 case 4: case 6: case 9: case 11:
never executed: case 4:
never executed: case 6:
never executed: case 9:
never executed: case 11:
0
793 if (d <= 30)
d <= 30Description
TRUEnever evaluated
FALSEnever evaluated
0
794 found = false;
never executed: found = false;
0
795 break;
never executed: break;
0
796 default:
never executed: default:
0
797 if (d > 0 && d <= 31)
d > 0Description
TRUEnever evaluated
FALSEnever evaluated
d <= 31Description
TRUEnever evaluated
FALSEnever evaluated
0
798 found = false;
never executed: found = false;
0
799 }
never executed: end of block
0
800 if (k == 0) findMatchingMonth = found;
never executed: findMatchingMonth = found;
k == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
801 else if (k == 1) findMatchingDay = found;
never executed: findMatchingDay = found;
k == 1Description
TRUEnever evaluated
FALSEnever evaluated
0
802 }
never executed: end of block
0
803 }
never executed: end of block
0
804 if (findMatchingMonth)
findMatchingMonthDescription
TRUEnever evaluated
FALSEnever evaluated
0
805 couldBe[i] &= ~ADAY;
never executed: couldBe[i] &= ~1;
0
806 if (findMatchingDay)
findMatchingDayDescription
TRUEnever evaluated
FALSEnever evaluated
0
807 couldBe[i] &= ~AMONTH;
never executed: couldBe[i] &= ~2;
0
808 }
never executed: end of block
0
809-
810 // First set the year/month/day that have been deduced-
811 // and reduce the set as we go along to deduce more-
812 for (int i = 0; i < unknownCount; ++i) {
i < unknownCountDescription
TRUEevaluated 322 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 267 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
267-322
813 int unset = 0;-
814 for (int j = 0; j < 3; ++j) {
j < 3Description
TRUEevaluated 552 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEnever evaluated
0-552
815 if (couldBe[j] == ADAY && day == -1) {
couldBe[j] == 1Description
TRUEevaluated 232 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 320 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
day == -1Description
TRUEevaluated 230 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
2-320
816 day = unknown[j];-
817 unset |= ADAY;-
818 } else if (couldBe[j] == AMONTH && month == -1) {
executed 230 times by 2 tests: end of block
Executed by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
couldBe[j] == 2Description
TRUEnever evaluated
FALSEevaluated 322 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
month == -1Description
TRUEnever evaluated
FALSEnever evaluated
0-322
819 month = unknown[j];-
820 unset |= AMONTH;-
821 } else if (couldBe[j] == AYEAR && year == -1) {
never executed: end of block
couldBe[j] == 4Description
TRUEnever evaluated
FALSEevaluated 322 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
year == -1Description
TRUEnever evaluated
FALSEnever evaluated
0-322
822 year = unknown[j];-
823 unset |= AYEAR;-
824 } else {
never executed: end of block
0
825 // common case-
826 break;
executed 322 times by 3 tests: break;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
322
827 }-
828 couldBe[j] &= ~unset;-
829 }
executed 230 times by 2 tests: end of block
Executed by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
230
830 }
executed 322 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
322
831-
832 // Now fallback to a standardized order to fill in the rest with-
833 for (int i = 0; i < unknownCount; ++i) {
i < unknownCountDescription
TRUEevaluated 322 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 267 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
267-322
834 if (couldBe[i] & AMONTH && month == -1) month = unknown[i];
executed 33 times by 1 test: month = unknown[i];
Executed by:
  • tst_qnetworkcookie - unknown status
couldBe[i] & 2Description
TRUEevaluated 52 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 270 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
month == -1Description
TRUEevaluated 33 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 19 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
19-270
835 else if (couldBe[i] & ADAY && day == -1) day = unknown[i];
executed 33 times by 2 tests: day = unknown[i];
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
couldBe[i] & 1Description
TRUEevaluated 59 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
FALSEevaluated 230 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
day == -1Description
TRUEevaluated 33 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
FALSEevaluated 26 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
26-230
836 else if (couldBe[i] & AYEAR && year == -1) year = unknown[i];
executed 24 times by 2 tests: year = unknown[i];
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
couldBe[i] & 4Description
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
FALSEevaluated 232 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
year == -1Description
TRUEevaluated 24 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
FALSEnever evaluated
0-232
837 }
executed 322 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
322
838#ifdef PARSEDATESTRINGDEBUG-
839 qDebug() << "Final set" << year << month << day;-
840#endif-
841-
842 if (year == -1 || month == -1 || day == -1) {
year == -1Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 262 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
month == -1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 261 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
day == -1Description
TRUEnever evaluated
FALSEevaluated 261 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
0-262
843#ifdef PARSEDATESTRINGDEBUG-
844 qDebug() << "Parser failure" << year << month << day;-
845#endif-
846 return QDateTime();
executed 6 times by 1 test: return QDateTime();
Executed by:
  • tst_qnetworkcookie - unknown status
6
847 }-
848-
849 // Y2k behavior-
850 int y2k = 0;-
851 if (year < 70)
year < 70Description
TRUEevaluated 27 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
FALSEevaluated 234 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
27-234
852 y2k = 2000;
executed 27 times by 2 tests: y2k = 2000;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
27
853 else if (year < 100)
year < 100Description
TRUEevaluated 68 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 166 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
68-166
854 y2k = 1900;
executed 68 times by 1 test: y2k = 1900;
Executed by:
  • tst_qnetworkcookie - unknown status
68
855-
856 QDate date(year + y2k, month, day);-
857-
858 // When we were given a bad cookie that when parsed-
859 // set the day to 29 and the year to one that doesn't-
860 // have the 29th of Feb rather then adding the extra-
861 // complicated checking earlier just swap here.-
862 // Example: 29 23 Feb-
863 if (!date.isValid())
!date.isValid()Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
FALSEevaluated 252 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
9-252
864 date = QDate(day + y2k, month, year);
executed 9 times by 1 test: date = QDate(day + y2k, month, year);
Executed by:
  • tst_qnetworkcookie - unknown status
9
865-
866 QDateTime dateTime(date, time, Qt::UTC);-
867-
868 if (zoneOffset != -1) {
zoneOffset != -1Description
TRUEevaluated 191 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 70 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
70-191
869 dateTime = dateTime.addSecs(zoneOffset);-
870 }
executed 191 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
191
871 if (!dateTime.isValid())
!dateTime.isValid()Description
TRUEnever evaluated
FALSEevaluated 261 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
0-261
872 return QDateTime();
never executed: return QDateTime();
0
873 return dateTime;
executed 261 times by 3 tests: return dateTime;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
261
874}-
875-
876/*!-
877 Parses the cookie string \a cookieString as received from a server-
878 response in the "Set-Cookie:" header. If there's a parsing error,-
879 this function returns an empty list.-
880-
881 Since the HTTP header can set more than one cookie at the same-
882 time, this function returns a QList<QNetworkCookie>, one for each-
883 cookie that is parsed.-
884-
885 \sa toRawForm()-
886*/-
887QList<QNetworkCookie> QNetworkCookie::parseCookies(const QByteArray &cookieString)-
888{-
889 // cookieString can be a number of set-cookie header strings joined together-
890 // by \n, parse each line separately.-
891 QList<QNetworkCookie> cookies;-
892 QList<QByteArray> list = cookieString.split('\n');-
893 for (int a = 0; a < list.size(); a++)
a < list.size()Description
TRUEevaluated 734 times by 5 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
FALSEevaluated 726 times by 5 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
726-734
894 cookies += QNetworkCookiePrivate::parseSetCookieHeaderLine(list.at(a));
executed 734 times by 5 tests: cookies += QNetworkCookiePrivate::parseSetCookieHeaderLine(list.at(a));
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
734
895 return cookies;
executed 726 times by 5 tests: return cookies;
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
726
896}-
897-
898QList<QNetworkCookie> QNetworkCookiePrivate::parseSetCookieHeaderLine(const QByteArray &cookieString)-
899{-
900 // According to http://wp.netscape.com/newsref/std/cookie_spec.html,<-
901 // the Set-Cookie response header is of the format:-
902 //-
903 // Set-Cookie: NAME=VALUE; expires=DATE; path=PATH; domain=DOMAIN_NAME; secure-
904 //-
905 // where only the NAME=VALUE part is mandatory-
906 //-
907 // We do not support RFC 2965 Set-Cookie2-style cookies-
908-
909 QList<QNetworkCookie> result;-
910 const QDateTime now = QDateTime::currentDateTimeUtc();-
911-
912 int position = 0;-
913 const int length = cookieString.length();-
914 while (position < length) {
position < lengthDescription
TRUEevaluated 728 times by 5 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
FALSEevaluated 680 times by 5 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
680-728
915 QNetworkCookie cookie;-
916-
917 // The first part is always the "NAME=VALUE" part-
918 QPair<QByteArray,QByteArray> field = nextField(cookieString, position, true);-
919 if (field.first.isEmpty())
field.first.isEmpty()Description
TRUEevaluated 46 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 682 times by 5 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
46-682
920 // parsing error-
921 break;
executed 46 times by 2 tests: break;
Executed by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
46
922 cookie.setName(field.first);-
923 cookie.setValue(field.second);-
924-
925 position = nextNonWhitespace(cookieString, position);-
926 while (position < length) {
position < lengthDescription
TRUEevaluated 683 times by 4 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
FALSEevaluated 674 times by 5 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
674-683
927 switch (cookieString.at(position++)) {-
928 case ';':
executed 683 times by 4 tests: case ';':
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
683
929 // new field in the cookie-
930 field = nextField(cookieString, position, false);-
931 field.first = field.first.toLower(); // everything but the NAME=VALUE is case-insensitive-
932-
933 if (field.first == "expires") {
field.first == "expires"Description
TRUEevaluated 267 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 416 times by 4 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
267-416
934 position -= field.second.length();-
935 int end;-
936 for (end = position; end < length; ++end)
end < lengthDescription
TRUEevaluated 6332 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 245 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
245-6332
937 if (isValueSeparator(cookieString.at(end)))
isValueSeparat...tring.at(end))Description
TRUEevaluated 22 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 6310 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
22-6310
938 break;
executed 22 times by 3 tests: break;
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
22
939-
940 QByteArray dateString = cookieString.mid(position, end - position).trimmed();-
941 position = end;-
942 QDateTime dt = parseDateString(dateString.toLower());-
943 if (dt.isValid())
dt.isValid()Description
TRUEevaluated 261 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_qnetworkcookie - unknown status
6-261
944 cookie.setExpirationDate(dt);
executed 261 times by 3 tests: cookie.setExpirationDate(dt);
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
261
945 //if unparsed, ignore the attribute but not the whole cookie (RFC6265 section 5.2.1)-
946 } else if (field.first == "domain") {
executed 267 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
field.first == "domain"Description
TRUEevaluated 122 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 294 times by 4 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
122-294
947 QByteArray rawDomain = field.second;-
948 //empty domain should be ignored (RFC6265 section 5.2.3)-
949 if (!rawDomain.isEmpty()) {
!rawDomain.isEmpty()Description
TRUEevaluated 118 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
4-118
950 QString maybeLeadingDot;-
951 if (rawDomain.startsWith('.')) {
rawDomain.startsWith('.')Description
TRUEevaluated 67 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 51 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
51-67
952 maybeLeadingDot = QLatin1Char('.');-
953 rawDomain = rawDomain.mid(1);-
954 }
executed 67 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
67
955-
956 //IDN domains are required by RFC6265, accepting utf8 as well doesn't break any test cases.-
957 QString normalizedDomain = QUrl::fromAce(QUrl::toAce(QString::fromUtf8(rawDomain)));-
958 if (!normalizedDomain.isEmpty()) {
!normalizedDomain.isEmpty()Description
TRUEevaluated 110 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 8 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
8-110
959 cookie.setDomain(maybeLeadingDot + normalizedDomain);-
960 } else {
executed 110 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
110
961 //Normalization fails for malformed domains, e.g. "..example.org", reject the cookie now-
962 //rather than accepting it but never sending it due to domain match failure, as the-
963 //strict reading of RFC6265 would indicate.-
964 return result;
executed 8 times by 2 tests: return result;
Executed by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
8
965 }-
966 }-
967 } else if (field.first == "max-age") {
executed 114 times by 3 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
field.first == "max-age"Description
TRUEevaluated 21 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 273 times by 4 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
21-273
968 bool ok = false;-
969 int secs = field.second.toInt(&ok);-
970 if (ok) {
okDescription
TRUEevaluated 19 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
2-19
971 if (secs <= 0) {
secs <= 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 11 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
8-11
972 //earliest representable time (RFC6265 section 5.2.2)-
973 cookie.setExpirationDate(QDateTime::fromTime_t(0));-
974 } else {
executed 8 times by 1 test: end of block
Executed by:
  • tst_qnetworkcookiejar - unknown status
8
975 cookie.setExpirationDate(now.addSecs(secs));-
976 }
executed 11 times by 2 tests: end of block
Executed by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
11
977 }-
978 //if unparsed, ignore the attribute but not the whole cookie (RFC6265 section 5.2.2)-
979 } else if (field.first == "path") {
executed 21 times by 2 tests: end of block
Executed by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
field.first == "path"Description
TRUEevaluated 145 times by 4 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
FALSEevaluated 128 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
21-145
980 if (field.second.startsWith('/')) {
field.second.startsWith('/')Description
TRUEevaluated 135 times by 4 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
FALSEevaluated 10 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
10-135
981 // ### we should treat cookie paths as an octet sequence internally-
982 // However RFC6265 says we should assume UTF-8 for presentation as a string-
983 cookie.setPath(QString::fromUtf8(field.second));-
984 } else {
executed 135 times by 4 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
135
985 // if the path doesn't start with '/' then set the default path (RFC6265 section 5.2.4)-
986 // and also IETF test case path0030 which has valid and empty path in the same cookie-
987 cookie.setPath(QString());-
988 }
executed 10 times by 2 tests: end of block
Executed by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
10
989 } else if (field.first == "secure") {
field.first == "secure"Description
TRUEevaluated 38 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 90 times by 3 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
38-90
990 cookie.setSecure(true);-
991 } else if (field.first == "httponly") {
executed 38 times by 2 tests: end of block
Executed by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
field.first == "httponly"Description
TRUEevaluated 17 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
FALSEevaluated 73 times by 2 tests
Evaluated by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
17-73
992 cookie.setHttpOnly(true);-
993 } else {
executed 17 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
17
994 // ignore unknown fields in the cookie (RFC6265 section 5.2, rule 6)-
995 }
executed 73 times by 2 tests: end of block
Executed by:
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
73
996-
997 position = nextNonWhitespace(cookieString, position);-
998 }
executed 675 times by 4 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
675
999 }
executed 675 times by 4 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
675
1000-
1001 if (!cookie.name().isEmpty())
!cookie.name().isEmpty()Description
TRUEevaluated 674 times by 5 tests
Evaluated by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
FALSEnever evaluated
0-674
1002 result += cookie;
executed 674 times by 5 tests: result += cookie;
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
674
1003 }
executed 674 times by 5 tests: end of block
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
674
1004-
1005 return result;
executed 726 times by 5 tests: return result;
Executed by:
  • tst_QNetworkDiskCache
  • tst_QNetworkReply
  • tst_qnetworkcookie - unknown status
  • tst_qnetworkcookiejar - unknown status
  • tst_qnetworkrequest - unknown status
726
1006}-
1007-
1008/*!-
1009 \since 5.0-
1010 This functions normalizes the path and domain of the cookie if they were previously empty.-
1011 The \a url parameter is used to determine the correct domain and path.-
1012*/-
1013void QNetworkCookie::normalize(const QUrl &url)-
1014{-
1015 // don't do path checking. See QTBUG-5815-
1016 if (d->path.isEmpty()) {
d->path.isEmpty()Description
TRUEevaluated 183 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 73 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
73-183
1017 QString pathAndFileName = url.path();-
1018 QString defaultPath = pathAndFileName.left(pathAndFileName.lastIndexOf(QLatin1Char('/'))+1);-
1019 if (defaultPath.isEmpty())
defaultPath.isEmpty()Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 180 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
3-180
1020 defaultPath = QLatin1Char('/');
executed 3 times by 1 test: defaultPath = QLatin1Char('/');
Executed by:
  • tst_qnetworkcookiejar - unknown status
3
1021 d->path = defaultPath;-
1022 }
executed 183 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
183
1023-
1024 if (d->domain.isEmpty()) {
d->domain.isEmpty()Description
TRUEevaluated 191 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 65 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
65-191
1025 d->domain = url.host();-
1026 } else {
executed 191 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
191
1027 QHostAddress hostAddress(d->domain);-
1028 if (hostAddress.protocol() != QAbstractSocket::IPv4Protocol
hostAddress.pr...::IPv4ProtocolDescription
TRUEevaluated 64 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
1-64
1029 && hostAddress.protocol() != QAbstractSocket::IPv6Protocol
hostAddress.pr...::IPv6ProtocolDescription
TRUEevaluated 63 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
1-63
1030 && !d->domain.startsWith(QLatin1Char('.'))) {
!d->domain.sta...tin1Char('.'))Description
TRUEevaluated 27 times by 1 test
Evaluated by:
  • tst_qnetworkcookiejar - unknown status
FALSEevaluated 36 times by 2 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
27-36
1031 // Ensure the domain starts with a dot if its field was not empty-
1032 // in the HTTP header. There are some servers that forget the-
1033 // leading dot and this is actually forbidden according to RFC 2109,-
1034 // but all browsers accept it anyway so we do that as well.-
1035 d->domain.prepend(QLatin1Char('.'));-
1036 }
executed 27 times by 1 test: end of block
Executed by:
  • tst_qnetworkcookiejar - unknown status
27
1037 }
executed 65 times by 2 tests: end of block
Executed by:
  • tst_QNetworkReply
  • tst_qnetworkcookiejar - unknown status
65
1038}-
1039-
1040#ifndef QT_NO_DEBUG_STREAM-
1041QDebug operator<<(QDebug s, const QNetworkCookie &cookie)-
1042{-
1043 QDebugStateSaver saver(s);-
1044 s.resetFormat().nospace();-
1045 s << "QNetworkCookie(" << cookie.toRawForm(QNetworkCookie::Full) << ')';-
1046 return s;
never executed: return s;
0
1047}-
1048#endif-
1049-
1050QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

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