access/qnetworkcookie.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4QNetworkCookie::QNetworkCookie(const QByteArray &name, const QByteArray &value) -
5 : d(new QNetworkCookiePrivate) -
6{ -
7 qRegisterMetaType<QNetworkCookie>(); -
8 qRegisterMetaType<QList<QNetworkCookie> >(); -
9 -
10 d->name = name; -
11 d->value = value; -
12}
executed: }
Execution Count:917
917
13 -
14 -
15 -
16 -
17 -
18QNetworkCookie::QNetworkCookie(const QNetworkCookie &other) -
19 : d(other.d) -
20{ -
21}
executed: }
Execution Count:2305
2305
22 -
23 -
24 -
25 -
26QNetworkCookie::~QNetworkCookie() -
27{ -
28 -
29 d = 0; -
30}
executed: }
Execution Count:3222
3222
31 -
32 -
33 -
34 -
35 -
36QNetworkCookie &QNetworkCookie::operator=(const QNetworkCookie &other) -
37{ -
38 d = other.d; -
39 return *this;
executed: return *this;
Execution Count:16
16
40} -
41bool QNetworkCookie::operator==(const QNetworkCookie &other) const -
42{ -
43 if (d == other.d)
evaluated: d == other.d
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:496
32-496
44 return true;
executed: return true;
Execution Count:32
32
45 return d->name == other.d->name && 496
46 d->value == other.d->value && 496
47 d->expirationDate.toUTC() == other.d->expirationDate.toUTC() && 496
48 d->domain == other.d->domain && 496
49 d->path == other.d->path && 496
50 d->secure == other.d->secure && 496
51 d->comment == other.d->comment;
executed: 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;
Execution Count:496
496
52} -
53 -
54 -
55 -
56 -
57 -
58 -
59 -
60bool QNetworkCookie::hasSameIdentifier(const QNetworkCookie &other) const -
61{ -
62 return d->name == other.d->name && d->domain == other.d->domain && d->path == other.d->path;
executed: return d->name == other.d->name && d->domain == other.d->domain && d->path == other.d->path;
Execution Count:45
45
63} -
64bool QNetworkCookie::isSecure() const -
65{ -
66 return d->secure;
executed: return d->secure;
Execution Count:1412
1412
67} -
68void QNetworkCookie::setSecure(bool enable) -
69{ -
70 d->secure = enable; -
71}
executed: }
Execution Count:44
44
72bool QNetworkCookie::isHttpOnly() const -
73{ -
74 return d->httpOnly;
executed: return d->httpOnly;
Execution Count:1205
1205
75} -
76 -
77 -
78 -
79 -
80 -
81 -
82void QNetworkCookie::setHttpOnly(bool enable) -
83{ -
84 d->httpOnly = enable; -
85}
executed: }
Execution Count:18
18
86bool QNetworkCookie::isSessionCookie() const -
87{ -
88 return !d->expirationDate.isValid();
executed: return !d->expirationDate.isValid();
Execution Count:1643
1643
89} -
90QDateTime QNetworkCookie::expirationDate() const -
91{ -
92 return d->expirationDate;
executed: return d->expirationDate;
Execution Count:252
252
93} -
94void QNetworkCookie::setExpirationDate(const QDateTime &date) -
95{ -
96 d->expirationDate = date; -
97}
executed: }
Execution Count:506
506
98QString QNetworkCookie::domain() const -
99{ -
100 return d->domain;
executed: return d->domain;
Execution Count:526
526
101} -
102 -
103 -
104 -
105 -
106 -
107 -
108void QNetworkCookie::setDomain(const QString &domain) -
109{ -
110 d->domain = domain; -
111}
executed: }
Execution Count:154
154
112 -
113 -
114 -
115 -
116 -
117 -
118 -
119QString QNetworkCookie::path() const -
120{ -
121 return d->path;
executed: return d->path;
Execution Count:309
309
122} -
123 -
124 -
125 -
126 -
127 -
128 -
129void QNetworkCookie::setPath(const QString &path) -
130{ -
131 d->path = path; -
132}
executed: }
Execution Count:196
196
133 -
134 -
135 -
136 -
137 -
138 -
139 -
140QByteArray QNetworkCookie::name() const -
141{ -
142 return d->name;
executed: return d->name;
Execution Count:979
979
143} -
144void QNetworkCookie::setName(const QByteArray &cookieName) -
145{ -
146 d->name = cookieName; -
147}
executed: }
Execution Count:856
856
148QByteArray QNetworkCookie::value() const -
149{ -
150 return d->value;
executed: return d->value;
Execution Count:307
307
151} -
152 -
153 -
154 -
155 -
156 -
157 -
158void QNetworkCookie::setValue(const QByteArray &value) -
159{ -
160 d->value = value; -
161}
executed: }
Execution Count:864
864
162 -
163 -
164static QPair<QByteArray, QByteArray> nextField(const QByteArray &text, int &position, bool isNameValue) -
165{ -
166 -
167 -
168 -
169 -
170 const int length = text.length(); -
171 position = nextNonWhitespace(text, position); -
172 -
173 int semiColonPosition = text.indexOf(';', position); -
174 if (semiColonPosition < 0)
evaluated: semiColonPosition < 0
TRUEFALSE
yes
Evaluation Count:715
yes
Evaluation Count:690
690-715
175 semiColonPosition = length;
executed: semiColonPosition = length;
Execution Count:715
715
176 -
177 int equalsPosition = text.indexOf('=', position); -
178 if (equalsPosition < 0 || equalsPosition > semiColonPosition) {
evaluated: equalsPosition < 0
TRUEFALSE
yes
Evaluation Count:124
yes
Evaluation Count:1281
evaluated: equalsPosition > semiColonPosition
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:1261
20-1281
179 if (isNameValue)
evaluated: isNameValue
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:110
34-110
180 return qMakePair(QByteArray(), QByteArray());
executed: return qMakePair(QByteArray(), QByteArray());
Execution Count:34
34
181 equalsPosition = semiColonPosition; -
182 }
executed: }
Execution Count:110
110
183 -
184 QByteArray first = text.mid(position, equalsPosition - position).trimmed(); -
185 QByteArray second; -
186 int secondLength = semiColonPosition - equalsPosition - 1; -
187 if (secondLength > 0)
evaluated: secondLength > 0
TRUEFALSE
yes
Evaluation Count:1232
yes
Evaluation Count:139
139-1232
188 second = text.mid(equalsPosition + 1, secondLength).trimmed();
executed: second = text.mid(equalsPosition + 1, secondLength).trimmed();
Execution Count:1232
1232
189 -
190 position = semiColonPosition; -
191 return qMakePair(first, second);
executed: return qMakePair(first, second);
Execution Count:1371
1371
192} -
193QByteArray QNetworkCookie::toRawForm(RawForm form) const -
194{ -
195 QByteArray result; -
196 if (d->name.isEmpty())
evaluated: d->name.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1219
2-1219
197 return result;
executed: return result;
Execution Count:2
2
198 -
199 result = d->name; -
200 result += '='; -
201 result += d->value; -
202 -
203 if (form == Full) {
evaluated: form == Full
TRUEFALSE
yes
Evaluation Count:1205
yes
Evaluation Count:14
14-1205
204 -
205 if (isSecure())
evaluated: isSecure()
TRUEFALSE
yes
Evaluation Count:64
yes
Evaluation Count:1141
64-1141
206 result += "; secure";
executed: result += "; secure";
Execution Count:64
64
207 if (isHttpOnly())
evaluated: isHttpOnly()
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:1165
40-1165
208 result += "; HttpOnly";
executed: result += "; HttpOnly";
Execution Count:40
40
209 if (!isSessionCookie()) {
evaluated: !isSessionCookie()
TRUEFALSE
yes
Evaluation Count:625
yes
Evaluation Count:580
580-625
210 result += "; expires="; -
211 result += QLocale::c().toString(d->expirationDate.toUTC(), -
212 QLatin1String("ddd, dd-MMM-yyyy hh:mm:ss 'GMT")).toLatin1(); -
213 }
executed: }
Execution Count:625
625
214 if (!d->domain.isEmpty()) {
evaluated: !d->domain.isEmpty()
TRUEFALSE
yes
Evaluation Count:226
yes
Evaluation Count:979
226-979
215 result += "; domain="; -
216 QString domainNoDot = d->domain; -
217 if (domainNoDot.startsWith(QLatin1Char('.'))) {
evaluated: domainNoDot.startsWith(QLatin1Char('.'))
TRUEFALSE
yes
Evaluation Count:178
yes
Evaluation Count:48
48-178
218 result += '.'; -
219 domainNoDot = domainNoDot.mid(1); -
220 }
executed: }
Execution Count:178
178
221 result += QUrl::toAce(domainNoDot); -
222 }
executed: }
Execution Count:226
226
223 if (!d->path.isEmpty()) {
evaluated: !d->path.isEmpty()
TRUEFALSE
yes
Evaluation Count:282
yes
Evaluation Count:923
282-923
224 result += "; path="; -
225 result += d->path.toUtf8(); -
226 }
executed: }
Execution Count:282
282
227 }
executed: }
Execution Count:1205
1205
228 return result;
executed: return result;
Execution Count:1219
1219
229} -
230 -
231static const char zones[] = -
232 "pst\0" -
233 "pdt\0" -
234 "mst\0" -
235 "mdt\0" -
236 "cst\0" -
237 "cdt\0" -
238 "est\0" -
239 "edt\0" -
240 "ast\0" -
241 "nst\0" -
242 "gmt\0" -
243 "utc\0" -
244 "bst\0" -
245 "met\0" -
246 "eet\0" -
247 "jst\0" -
248 "\0"; -
249static int zoneOffsets[] = {-8, -8, -7, -7, -6, -6, -5, -5, -4, -3, 0, 0, 0, 1, 2, 9 }; -
250 -
251static const char months[] = -
252 "jan\0" -
253 "feb\0" -
254 "mar\0" -
255 "apr\0" -
256 "may\0" -
257 "jun\0" -
258 "jul\0" -
259 "aug\0" -
260 "sep\0" -
261 "oct\0" -
262 "nov\0" -
263 "dec\0" -
264 "\0"; -
265 -
266static inline bool isNumber(char s) -
267{ return s >= '0' && s <= '9'; }
executed: return s >= '0' && s <= '9';
Execution Count:4711
4711
268 -
269static inline bool isTerminator(char c) -
270{ return c == '\n' || c == '\r'; }
executed: return c == '\n' || c == '\r';
Execution Count:6304
6304
271 -
272static inline bool isValueSeparator(char c) -
273{ return isTerminator(c) || c == ';'; }
executed: return isTerminator(c) || c == ';';
Execution Count:6304
6304
274 -
275static inline bool isWhitespace(char c) -
276{ return c == ' ' || c == '\t'; }
executed: return c == ' ' || c == '\t';
Execution Count:313
313
277 -
278static bool checkStaticArray(int &val, const QByteArray &dateString, int at, const char *array, int size) -
279{ -
280 if (dateString[at] < 'a' || dateString[at] > 'z')
evaluated: dateString[at] < 'a'
TRUEFALSE
yes
Evaluation Count:2625
yes
Evaluation Count:1791
partially evaluated: dateString[at] > 'z'
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1791
0-2625
281 return false;
executed: return false;
Execution Count:2625
2625
282 if (val == -1 && dateString.length() >= at + 3) {
evaluated: val == -1
TRUEFALSE
yes
Evaluation Count:1573
yes
Evaluation Count:218
evaluated: dateString.length() >= at + 3
TRUEFALSE
yes
Evaluation Count:1563
yes
Evaluation Count:10
10-1573
283 int j = 0; -
284 int i = 0; -
285 while (i <= size) {
evaluated: i <= size
TRUEFALSE
yes
Evaluation Count:21389
yes
Evaluation Count:1150
1150-21389
286 const char *str = array + i; -
287 if (str[0] == dateString[at]
evaluated: str[0] == dateString[at]
TRUEFALSE
yes
Evaluation Count:1142
yes
Evaluation Count:20247
1142-20247
288 && str[1] == dateString[at + 1]
evaluated: str[1] == dateString[at + 1]
TRUEFALSE
yes
Evaluation Count:457
yes
Evaluation Count:685
457-685
289 && str[2] == dateString[at + 2]) {
evaluated: str[2] == dateString[at + 2]
TRUEFALSE
yes
Evaluation Count:413
yes
Evaluation Count:44
44-413
290 val = j; -
291 return true;
executed: return true;
Execution Count:413
413
292 } -
293 i += int(strlen(str)) + 1; -
294 ++j; -
295 }
executed: }
Execution Count:20976
20976
296 }
executed: }
Execution Count:1150
1150
297 return false;
executed: return false;
Execution Count:1378
1378
298} -
299static QDateTime parseDateString(const QByteArray &dateString) -
300{ -
301 QTime time; -
302 -
303 int unknown[3] = {-1, -1, -1}; -
304 int month = -1; -
305 int day = -1; -
306 int year = -1; -
307 int zoneOffset = -1; -
308 -
309 -
310 QRegExp timeRx(QLatin1String("(\\d{1,2}):(\\d{1,2})(:(\\d{1,2})|)(\\.(\\d{1,3})|)((\\s{0,}(am|pm))|)")); -
311 -
312 int at = 0; -
313 while (at < dateString.length()) {
evaluated: at < dateString.length()
TRUEFALSE
yes
Evaluation Count:3162
yes
Evaluation Count:266
266-3162
314 -
315 -
316 -
317 bool isNum = isNumber(dateString[at]); -
318 -
319 -
320 if (!isNum
evaluated: !isNum
TRUEFALSE
yes
Evaluation Count:2343
yes
Evaluation Count:819
819-2343
321 && checkStaticArray(month, dateString, at, months, sizeof(months)- 1)) {
evaluated: checkStaticArray(month, dateString, at, months, sizeof(months)- 1)
TRUEFALSE
yes
Evaluation Count:228
yes
Evaluation Count:2115
228-2115
322 ++month; -
323 -
324 -
325 -
326 at += 3; -
327 continue;
executed: continue;
Execution Count:228
228
328 } -
329 -
330 if (!isNum
evaluated: !isNum
TRUEFALSE
yes
Evaluation Count:2115
yes
Evaluation Count:819
819-2115
331 && zoneOffset == -1
evaluated: zoneOffset == -1
TRUEFALSE
yes
Evaluation Count:2073
yes
Evaluation Count:42
42-2073
332 && checkStaticArray(zoneOffset, dateString, at, zones, sizeof(zones)- 1)) {
evaluated: checkStaticArray(zoneOffset, dateString, at, zones, sizeof(zones)- 1)
TRUEFALSE
yes
Evaluation Count:185
yes
Evaluation Count:1888
185-1888
333 int sign = (at >= 0 && dateString[at - 1] == '-') ? -1 : 1;
partially evaluated: at >= 0
TRUEFALSE
yes
Evaluation Count:185
no
Evaluation Count:0
evaluated: dateString[at - 1] == '-'
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:184
0-185
334 zoneOffset = sign * zoneOffsets[zoneOffset] * 60 * 60; -
335 -
336 -
337 -
338 at += 3; -
339 continue;
executed: continue;
Execution Count:185
185
340 } -
341 -
342 if (!isNum
evaluated: !isNum
TRUEFALSE
yes
Evaluation Count:1930
yes
Evaluation Count:819
819-1930
343 && (zoneOffset == -1 || zoneOffset == 0)
evaluated: zoneOffset == -1
TRUEFALSE
yes
Evaluation Count:1888
yes
Evaluation Count:42
evaluated: zoneOffset == 0
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:15
15-1888
344 && (dateString[at] == '+' || dateString[at] == '-')
evaluated: dateString[at] == '+'
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:1906
evaluated: dateString[at] == '-'
TRUEFALSE
yes
Evaluation Count:304
yes
Evaluation Count:1602
9-1906
345 && (at == 0
partially evaluated: at == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:313
0-313
346 || isWhitespace(dateString[at - 1])
evaluated: isWhitespace(dateString[at - 1])
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:306
7-306
347 || dateString[at - 1] == ','
partially evaluated: dateString[at - 1] == ','
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:306
0-306
348 || (at >= 3
evaluated: at >= 3
TRUEFALSE
yes
Evaluation Count:299
yes
Evaluation Count:7
7-299
349 && (dateString[at - 3] == 'g')
evaluated: (dateString[at - 3] == 'g')
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:294
5-294
350 && (dateString[at - 2] == 'm')
partially evaluated: (dateString[at - 2] == 'm')
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
351 && (dateString[at - 1] == 't')))) {
partially evaluated: (dateString[at - 1] == 't')
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
352 -
353 int end = 1; -
354 while (end < 5 && dateString.length() > at+end
evaluated: end < 5
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:5
evaluated: dateString.length() > at+end
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:7
5-38
355 && dateString[at + end] >= '0' && dateString[at + end] <= '9')
partially evaluated: dateString[at + end] >= '0'
TRUEFALSE
yes
Evaluation Count:31
no
Evaluation Count:0
partially evaluated: dateString[at + end] <= '9'
TRUEFALSE
yes
Evaluation Count:31
no
Evaluation Count:0
0-31
356 ++end;
executed: ++end;
Execution Count:31
31
357 int minutes = 0; -
358 int hours = 0; -
359 switch (end - 1) { -
360 case 4: -
361 minutes = atoi(dateString.mid(at + 3, 2).constData()); -
362 -
363 case 2:
code before this statement executed: case 2:
Execution Count:5
5
364 hours = atoi(dateString.mid(at + 1, 2).constData()); -
365 break;
executed: break;
Execution Count:7
7
366 case 1: -
367 hours = atoi(dateString.mid(at + 1, 1).constData()); -
368 break;
executed: break;
Execution Count:4
4
369 default: -
370 at += end; -
371 continue;
executed: continue;
Execution Count:1
1
372 } -
373 if (end != 1) {
partially evaluated: end != 1
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
374 int sign = dateString[at] == '-' ? -1 : 1;
evaluated: dateString[at] == '-'
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:8
3-8
375 zoneOffset = sign * ((minutes * 60) + (hours * 60 * 60)); -
376 -
377 -
378 -
379 at += end; -
380 continue;
executed: continue;
Execution Count:11
11
381 } -
382 }
never executed: }
0
383 -
384 -
385 if (isNum && time.isNull()
evaluated: isNum
TRUEFALSE
yes
Evaluation Count:819
yes
Evaluation Count:1918
evaluated: time.isNull()
TRUEFALSE
yes
Evaluation Count:802
yes
Evaluation Count:17
17-1918
386 && dateString.length() >= at + 3
evaluated: dateString.length() >= at + 3
TRUEFALSE
yes
Evaluation Count:801
yes
Evaluation Count:1
1-801
387 && (dateString[at + 2] == ':' || dateString[at + 1] == ':')) {
evaluated: dateString[at + 2] == ':'
TRUEFALSE
yes
Evaluation Count:183
yes
Evaluation Count:618
evaluated: dateString[at + 1] == ':'
TRUEFALSE
yes
Evaluation Count:78
yes
Evaluation Count:540
78-618
388 -
389 -
390 int pos = timeRx.indexIn(QLatin1String(dateString), at); -
391 if (pos != -1) {
partially evaluated: pos != -1
TRUEFALSE
yes
Evaluation Count:261
no
Evaluation Count:0
0-261
392 QStringList list = timeRx.capturedTexts(); -
393 int h = atoi(list.at(1).toLatin1().constData()); -
394 int m = atoi(list.at(2).toLatin1().constData()); -
395 int s = atoi(list.at(4).toLatin1().constData()); -
396 int ms = atoi(list.at(6).toLatin1().constData()); -
397 if (h < 12 && !list.at(9).isEmpty())
evaluated: h < 12
TRUEFALSE
yes
Evaluation Count:198
yes
Evaluation Count:63
evaluated: !list.at(9).isEmpty()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:190
8-198
398 if (list.at(9) == QLatin1String("pm"))
evaluated: list.at(9) == QLatin1String("pm")
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2
2-6
399 h += 12;
executed: h += 12;
Execution Count:6
6
400 time = QTime(h, m, s, ms); -
401 -
402 -
403 -
404 at += timeRx.matchedLength(); -
405 continue;
executed: continue;
Execution Count:261
261
406 } -
407 }
never executed: }
0
408 -
409 -
410 if (isNum
evaluated: isNum
TRUEFALSE
yes
Evaluation Count:558
yes
Evaluation Count:1918
558-1918
411 && year == -1
evaluated: year == -1
TRUEFALSE
yes
Evaluation Count:536
yes
Evaluation Count:22
22-536
412 && dateString.length() > at + 3) {
evaluated: dateString.length() > at + 3
TRUEFALSE
yes
Evaluation Count:532
yes
Evaluation Count:4
4-532
413 if (isNumber(dateString[at + 1])
evaluated: isNumber(dateString[at + 1])
TRUEFALSE
yes
Evaluation Count:461
yes
Evaluation Count:71
71-461
414 && isNumber(dateString[at + 2])
evaluated: isNumber(dateString[at + 2])
TRUEFALSE
yes
Evaluation Count:166
yes
Evaluation Count:295
166-295
415 && isNumber(dateString[at + 3])) {
partially evaluated: isNumber(dateString[at + 3])
TRUEFALSE
yes
Evaluation Count:166
no
Evaluation Count:0
0-166
416 year = atoi(dateString.mid(at, 4).constData()); -
417 at += 4; -
418 -
419 -
420 -
421 continue;
executed: continue;
Execution Count:166
166
422 } -
423 }
executed: }
Execution Count:366
366
424 -
425 -
426 -
427 if (isNum) {
evaluated: isNum
TRUEFALSE
yes
Evaluation Count:392
yes
Evaluation Count:1918
392-1918
428 int length = 1; -
429 if (dateString.length() > at + 1
evaluated: dateString.length() > at + 1
TRUEFALSE
yes
Evaluation Count:390
yes
Evaluation Count:2
2-390
430 && isNumber(dateString[at + 1]))
evaluated: isNumber(dateString[at + 1])
TRUEFALSE
yes
Evaluation Count:312
yes
Evaluation Count:78
78-312
431 ++length;
executed: ++length;
Execution Count:312
312
432 int x = atoi(dateString.mid(at, length).constData()); -
433 if (year == -1 && (x > 31 || x == 0)) {
evaluated: year == -1
TRUEFALSE
yes
Evaluation Count:370
yes
Evaluation Count:22
evaluated: x > 31
TRUEFALSE
yes
Evaluation Count:70
yes
Evaluation Count:300
evaluated: x == 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:298
2-370
434 year = x; -
435 } else {
executed: }
Execution Count:72
72
436 if (unknown[0] == -1) unknown[0] = x;
evaluated: unknown[0] == -1
TRUEFALSE
yes
Evaluation Count:262
yes
Evaluation Count:58
executed: unknown[0] = x;
Execution Count:262
58-262
437 else if (unknown[1] == -1) unknown[1] = x;
evaluated: unknown[1] == -1
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:18
executed: unknown[1] = x;
Execution Count:40
18-40
438 else if (unknown[2] == -1) unknown[2] = x;
partially evaluated: unknown[2] == -1
TRUEFALSE
yes
Evaluation Count:18
no
Evaluation Count:0
executed: unknown[2] = x;
Execution Count:18
0-18
439 } -
440 at += length; -
441 -
442 -
443 -
444 continue;
executed: continue;
Execution Count:392
392
445 } -
446 -
447 -
448 ++at; -
449 }
executed: }
Execution Count:1918
1918
450 -
451 -
452 -
453 -
454 int couldBe[3] = { 0, 0, 0 }; -
455 int unknownCount = 3; -
456 for (int i = 0; i < unknownCount; ++i) {
evaluated: i < unknownCount
TRUEFALSE
yes
Evaluation Count:568
yes
Evaluation Count:266
266-568
457 if (unknown[i] == -1) {
evaluated: unknown[i] == -1
TRUEFALSE
yes
Evaluation Count:248
yes
Evaluation Count:320
248-320
458 couldBe[i] = 1 | 4 | 2; -
459 unknownCount = i; -
460 continue;
executed: continue;
Execution Count:248
248
461 } -
462 -
463 if (unknown[i] >= 1)
partially evaluated: unknown[i] >= 1
TRUEFALSE
yes
Evaluation Count:320
no
Evaluation Count:0
0-320
464 couldBe[i] = 1;
executed: couldBe[i] = 1;
Execution Count:320
320
465 -
466 if (month == -1 && unknown[i] >= 1 && unknown[i] <= 12)
evaluated: month == -1
TRUEFALSE
yes
Evaluation Count:86
yes
Evaluation Count:234
partially evaluated: unknown[i] >= 1
TRUEFALSE
yes
Evaluation Count:86
no
Evaluation Count:0
evaluated: unknown[i] <= 12
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:34
0-234
467 couldBe[i] |= 2;
executed: couldBe[i] |= 2;
Execution Count:52
52
468 -
469 if (year == -1)
evaluated: year == -1
TRUEFALSE
yes
Evaluation Count:66
yes
Evaluation Count:254
66-254
470 couldBe[i] |= 4;
executed: couldBe[i] |= 4;
Execution Count:66
66
471 }
executed: }
Execution Count:320
320
472 -
473 -
474 -
475 -
476 -
477 -
478 -
479 for (int i = 0; i < unknownCount; ++i) {
evaluated: i < unknownCount
TRUEFALSE
yes
Evaluation Count:320
yes
Evaluation Count:266
266-320
480 int currentValue = unknown[i]; -
481 bool findMatchingMonth = couldBe[i] & 1 && currentValue >= 29;
partially evaluated: couldBe[i] & 1
TRUEFALSE
yes
Evaluation Count:320
no
Evaluation Count:0
evaluated: currentValue >= 29
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:294
0-320
482 bool findMatchingDay = couldBe[i] & 2; -
483 if (!findMatchingMonth || !findMatchingDay)
evaluated: !findMatchingMonth
TRUEFALSE
yes
Evaluation Count:294
yes
Evaluation Count:26
partially evaluated: !findMatchingDay
TRUEFALSE
yes
Evaluation Count:26
no
Evaluation Count:0
0-294
484 continue;
executed: continue;
Execution Count:320
320
485 for (int j = 0; j < 3; ++j) {
never evaluated: j < 3
0
486 if (j == i)
never evaluated: j == i
0
487 continue;
never executed: continue;
0
488 for (int k = 0; k < 2; ++k) {
never evaluated: k < 2
0
489 if (k == 0 && !(findMatchingMonth && (couldBe[j] & 2)))
never evaluated: k == 0
never evaluated: findMatchingMonth
never evaluated: (couldBe[j] & 2)
0
490 continue;
never executed: continue;
0
491 else if (k == 1 && !(findMatchingDay && (couldBe[j] & 1)))
never evaluated: k == 1
never evaluated: findMatchingDay
never evaluated: (couldBe[j] & 1)
0
492 continue;
never executed: continue;
0
493 int m = currentValue; -
494 int d = unknown[j]; -
495 if (k == 0)
never evaluated: k == 0
0
496 qSwap(m, d);
never executed: qSwap(m, d);
0
497 if (m == -1) m = month;
never evaluated: m == -1
never executed: m = month;
0
498 bool found = true; -
499 switch(m) { -
500 case 2: -
501 -
502 -
503 -
504 if (d <= 29)
never evaluated: d <= 29
0
505 found = false;
never executed: found = false;
0
506 break;
never executed: break;
0
507 case 4: case 6: case 9: case 11: -
508 if (d <= 30)
never evaluated: d <= 30
0
509 found = false;
never executed: found = false;
0
510 break;
never executed: break;
0
511 default: -
512 if (d > 0 && d <= 31)
never evaluated: d > 0
never evaluated: d <= 31
0
513 found = false;
never executed: found = false;
0
514 }
never executed: }
0
515 if (k == 0) findMatchingMonth = found;
never evaluated: k == 0
never executed: findMatchingMonth = found;
0
516 else if (k == 1) findMatchingDay = found;
never evaluated: k == 1
never executed: findMatchingDay = found;
0
517 } -
518 }
never executed: }
0
519 if (findMatchingMonth)
never evaluated: findMatchingMonth
0
520 couldBe[i] &= ~1;
never executed: couldBe[i] &= ~1;
0
521 if (findMatchingDay)
never evaluated: findMatchingDay
0
522 couldBe[i] &= ~2;
never executed: couldBe[i] &= ~2;
0
523 }
never executed: }
0
524 -
525 -
526 -
527 for (int i = 0; i < unknownCount; ++i) {
evaluated: i < unknownCount
TRUEFALSE
yes
Evaluation Count:320
yes
Evaluation Count:266
266-320
528 int unset = 0; -
529 for (int j = 0; j < 3; ++j) {
partially evaluated: j < 3
TRUEFALSE
yes
Evaluation Count:550
no
Evaluation Count:0
0-550
530 if (couldBe[j] == 1 && day == -1) {
evaluated: couldBe[j] == 1
TRUEFALSE
yes
Evaluation Count:232
yes
Evaluation Count:318
evaluated: day == -1
TRUEFALSE
yes
Evaluation Count:230
yes
Evaluation Count:2
2-318
531 day = unknown[j]; -
532 unset |= 1; -
533 } else if (couldBe[j] == 2 && month == -1) {
partially evaluated: couldBe[j] == 2
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:320
never evaluated: month == -1
executed: }
Execution Count:230
0-320
534 month = unknown[j]; -
535 unset |= 2; -
536 } else if (couldBe[j] == 4 && year == -1) {
partially evaluated: couldBe[j] == 4
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:320
never evaluated: year == -1
never executed: }
0-320
537 year = unknown[j]; -
538 unset |= 4; -
539 } else {
never executed: }
0
540 -
541 break;
executed: break;
Execution Count:320
320
542 } -
543 couldBe[j] &= ~unset; -
544 }
executed: }
Execution Count:230
230
545 }
executed: }
Execution Count:320
320
546 -
547 -
548 for (int i = 0; i < unknownCount; ++i) {
evaluated: i < unknownCount
TRUEFALSE
yes
Evaluation Count:320
yes
Evaluation Count:266
266-320
549 if (couldBe[i] & 2 && month == -1) month = unknown[i];
evaluated: couldBe[i] & 2
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:268
evaluated: month == -1
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:19
executed: month = unknown[i];
Execution Count:33
19-268
550 else if (couldBe[i] & 1 && day == -1) day = unknown[i];
evaluated: couldBe[i] & 1
TRUEFALSE
yes
Evaluation Count:57
yes
Evaluation Count:230
evaluated: day == -1
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:25
executed: day = unknown[i];
Execution Count:32
25-230
551 else if (couldBe[i] & 4 && year == -1) year = unknown[i];
evaluated: couldBe[i] & 4
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:232
partially evaluated: year == -1
TRUEFALSE
yes
Evaluation Count:23
no
Evaluation Count:0
executed: year = unknown[i];
Execution Count:23
0-232
552 } -
553 -
554 -
555 -
556 -
557 if (year == -1 || month == -1 || day == -1) {
evaluated: year == -1
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:261
evaluated: month == -1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:260
partially evaluated: day == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:260
0-261
558 -
559 -
560 -
561 return QDateTime();
executed: return QDateTime();
Execution Count:6
6
562 } -
563 -
564 -
565 int y2k = 0; -
566 if (year < 70)
evaluated: year < 70
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:234
26-234
567 y2k = 2000;
executed: y2k = 2000;
Execution Count:26
26
568 else if (year < 100)
evaluated: year < 100
TRUEFALSE
yes
Evaluation Count:68
yes
Evaluation Count:166
68-166
569 y2k = 1900;
executed: y2k = 1900;
Execution Count:68
68
570 -
571 QDate date(year + y2k, month, day); -
572 -
573 -
574 -
575 -
576 -
577 -
578 if (!date.isValid())
evaluated: !date.isValid()
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:251
9-251
579 date = QDate(day + y2k, month, year);
executed: date = QDate(day + y2k, month, year);
Execution Count:9
9
580 -
581 QDateTime dateTime(date, time, Qt::UTC); -
582 -
583 if (zoneOffset != -1) {
evaluated: zoneOffset != -1
TRUEFALSE
yes
Evaluation Count:190
yes
Evaluation Count:70
70-190
584 dateTime = dateTime.addSecs(zoneOffset); -
585 }
executed: }
Execution Count:190
190
586 if (!dateTime.isValid())
partially evaluated: !dateTime.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:260
0-260
587 return QDateTime();
never executed: return QDateTime();
0
588 return dateTime;
executed: return dateTime;
Execution Count:260
260
589} -
590QList<QNetworkCookie> QNetworkCookie::parseCookies(const QByteArray &cookieString) -
591{ -
592 -
593 -
594 QList<QNetworkCookie> cookies; -
595 QList<QByteArray> list = cookieString.split('\n'); -
596 for (int a = 0; a < list.size(); a++)
evaluated: a < list.size()
TRUEFALSE
yes
Evaluation Count:732
yes
Evaluation Count:724
724-732
597 cookies += QNetworkCookiePrivate::parseSetCookieHeaderLine(list.at(a));
executed: cookies += QNetworkCookiePrivate::parseSetCookieHeaderLine(list.at(a));
Execution Count:732
732
598 return cookies;
executed: return cookies;
Execution Count:724
724
599} -
600 -
601QList<QNetworkCookie> QNetworkCookiePrivate::parseSetCookieHeaderLine(const QByteArray &cookieString) -
602{ -
603 QList<QNetworkCookie> result; -
604 QDateTime now = QDateTime::currentDateTime().toUTC(); -
605 -
606 int position = 0; -
607 const int length = cookieString.length(); -
608 while (position < length) {
evaluated: position < length
TRUEFALSE
yes
Evaluation Count:726
yes
Evaluation Count:678
678-726
609 QNetworkCookie cookie; -
610 -
611 -
612 QPair<QByteArray,QByteArray> field = nextField(cookieString, position, true); -
613 if (field.first.isEmpty())
evaluated: field.first.isEmpty()
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:680
46-680
614 -
615 break;
executed: break;
Execution Count:46
46
616 cookie.setName(field.first); -
617 cookie.setValue(field.second); -
618 -
619 position = nextNonWhitespace(cookieString, position); -
620 while (position < length) {
evaluated: position < length
TRUEFALSE
yes
Evaluation Count:679
yes
Evaluation Count:672
672-679
621 switch (cookieString.at(position++)) { -
622 case ';': -
623 -
624 field = nextField(cookieString, position, false); -
625 field.first = field.first.toLower(); -
626 -
627 if (field.first == "expires") {
evaluated: field.first == "expires"
TRUEFALSE
yes
Evaluation Count:266
yes
Evaluation Count:413
266-413
628 position -= field.second.length(); -
629 int end; -
630 for (end = position; end < length; ++end)
evaluated: end < length
TRUEFALSE
yes
Evaluation Count:6304
yes
Evaluation Count:245
245-6304
631 if (isValueSeparator(cookieString.at(end)))
evaluated: isValueSeparator(cookieString.at(end))
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:6283
21-6283
632 break;
executed: break;
Execution Count:21
21
633 -
634 QByteArray dateString = cookieString.mid(position, end - position).trimmed(); -
635 position = end; -
636 QDateTime dt = parseDateString(dateString.toLower()); -
637 if (dt.isValid())
evaluated: dt.isValid()
TRUEFALSE
yes
Evaluation Count:260
yes
Evaluation Count:6
6-260
638 cookie.setExpirationDate(dt);
executed: cookie.setExpirationDate(dt);
Execution Count:260
260
639 -
640 } else if (field.first == "domain") {
executed: }
Execution Count:266
evaluated: field.first == "domain"
TRUEFALSE
yes
Evaluation Count:121
yes
Evaluation Count:292
121-292
641 QByteArray rawDomain = field.second; -
642 -
643 if (!rawDomain.isEmpty()) {
evaluated: !rawDomain.isEmpty()
TRUEFALSE
yes
Evaluation Count:117
yes
Evaluation Count:4
4-117
644 QString maybeLeadingDot; -
645 if (rawDomain.startsWith('.')) {
evaluated: rawDomain.startsWith('.')
TRUEFALSE
yes
Evaluation Count:66
yes
Evaluation Count:51
51-66
646 maybeLeadingDot = QLatin1Char('.'); -
647 rawDomain = rawDomain.mid(1); -
648 }
executed: }
Execution Count:66
66
649 -
650 -
651 QString normalizedDomain = QUrl::fromAce(QUrl::toAce(QString::fromUtf8(rawDomain))); -
652 if (!normalizedDomain.isEmpty()) {
evaluated: !normalizedDomain.isEmpty()
TRUEFALSE
yes
Evaluation Count:109
yes
Evaluation Count:8
8-109
653 cookie.setDomain(maybeLeadingDot + normalizedDomain); -
654 } else {
executed: }
Execution Count:109
109
655 -
656 -
657 -
658 return result;
executed: return result;
Execution Count:8
8
659 } -
660 } -
661 } else if (field.first == "max-age") {
executed: }
Execution Count:113
evaluated: field.first == "max-age"
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:271
21-271
662 bool ok = false; -
663 int secs = field.second.toInt(&ok); -
664 if (ok) {
evaluated: ok
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:2
2-19
665 if (secs <= 0) {
evaluated: secs <= 0
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:11
8-11
666 -
667 cookie.setExpirationDate(QDateTime::fromTime_t(0)); -
668 } else {
executed: }
Execution Count:8
8
669 cookie.setExpirationDate(now.addSecs(secs)); -
670 }
executed: }
Execution Count:11
11
671 } -
672 -
673 } else if (field.first == "path") {
executed: }
Execution Count:21
evaluated: field.first == "path"
TRUEFALSE
yes
Evaluation Count:144
yes
Evaluation Count:127
21-144
674 if (field.second.startsWith('/')) {
evaluated: field.second.startsWith('/')
TRUEFALSE
yes
Evaluation Count:134
yes
Evaluation Count:10
10-134
675 -
676 -
677 cookie.setPath(QString::fromUtf8(field.second)); -
678 } else {
executed: }
Execution Count:134
134
679 -
680 -
681 cookie.setPath(QString()); -
682 }
executed: }
Execution Count:10
10
683 } else if (field.first == "secure") {
evaluated: field.first == "secure"
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:89
38-89
684 cookie.setSecure(true); -
685 } else if (field.first == "httponly") {
executed: }
Execution Count:38
evaluated: field.first == "httponly"
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:73
16-73
686 cookie.setHttpOnly(true); -
687 } else {
executed: }
Execution Count:16
16
688 -
689 }
executed: }
Execution Count:73
73
690 -
691 position = nextNonWhitespace(cookieString, position); -
692 }
executed: }
Execution Count:671
671
693 }
executed: }
Execution Count:671
671
694 -
695 if (!cookie.name().isEmpty())
partially evaluated: !cookie.name().isEmpty()
TRUEFALSE
yes
Evaluation Count:672
no
Evaluation Count:0
0-672
696 result += cookie;
executed: result += cookie;
Execution Count:672
672
697 }
executed: }
Execution Count:672
672
698 -
699 return result;
executed: return result;
Execution Count:724
724
700} -
701 -
702 -
703 -
704 -
705 -
706 -
707void QNetworkCookie::normalize(const QUrl &url) -
708{ -
709 -
710 if (d->path.isEmpty()) {
evaluated: d->path.isEmpty()
TRUEFALSE
yes
Evaluation Count:183
yes
Evaluation Count:70
70-183
711 QString pathAndFileName = url.path(); -
712 QString defaultPath = pathAndFileName.left(pathAndFileName.lastIndexOf(QLatin1Char('/'))+1); -
713 if (defaultPath.isEmpty())
evaluated: defaultPath.isEmpty()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:180
3-180
714 defaultPath = QLatin1Char('/');
executed: defaultPath = QLatin1Char('/');
Execution Count:3
3
715 d->path = defaultPath; -
716 }
executed: }
Execution Count:183
183
717 -
718 if (d->domain.isEmpty())
evaluated: d->domain.isEmpty()
TRUEFALSE
yes
Evaluation Count:191
yes
Evaluation Count:62
62-191
719 d->domain = url.host();
executed: d->domain = url.host();
Execution Count:191
191
720 else if (!d->domain.startsWith(QLatin1Char('.')))
evaluated: !d->domain.startsWith(QLatin1Char('.'))
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:35
27-35
721 -
722 -
723 -
724 -
725 d->domain.prepend(QLatin1Char('.'));
executed: d->domain.prepend(QLatin1Char('.'));
Execution Count:27
27
726} -
727 -
728 -
729QDebug operator<<(QDebug s, const QNetworkCookie &cookie) -
730{ -
731 s.nospace() << "QNetworkCookie(" << cookie.toRawForm(QNetworkCookie::Full) << ')'; -
732 return s.space();
never executed: return s.space();
0
733} -
734 -
735 -
736 -
737 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial