io/qtldurl.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4static bool containsTLDEntry(const QString &entry) -
5{ -
6 int index = qt_hash(entry) % tldCount; -
7 int currentDomainIndex = tldIndices[index]; -
8 while (currentDomainIndex < tldIndices[index+1]) {
evaluated: currentDomainIndex < tldIndices[index+1]
TRUEFALSE
yes
Evaluation Count:563
yes
Evaluation Count:510
510-563
9 QString currentEntry = QString::fromUtf8(tldData + currentDomainIndex); -
10 if (currentEntry == entry)
evaluated: currentEntry == entry
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:539
24-539
11 return true;
executed: return true;
Execution Count:24
24
12 currentDomainIndex += qstrlen(tldData + currentDomainIndex) + 1; -
13 }
executed: }
Execution Count:539
539
14 return false;
executed: return false;
Execution Count:510
510
15} -
16__attribute__((visibility("default"))) QString qTopLevelDomain(const QString &domain) -
17{ -
18 QStringList sections = domain.toLower().split(QLatin1Char('.'), QString::SkipEmptyParts); -
19 if (sections.isEmpty())
partially evaluated: sections.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
20 return QString();
never executed: return QString();
0
21 -
22 QString level, tld; -
23 for (int j = sections.count() - 1; j >= 0; --j) {
evaluated: j >= 0
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:9
9-34
24 level.prepend(QLatin1Char('.') + sections.at(j)); -
25 if (qIsEffectiveTLD(level.right(level.size() - 1)))
evaluated: qIsEffectiveTLD(level.right(level.size() - 1))
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:19
15-19
26 tld = level;
executed: tld = level;
Execution Count:15
15
27 }
executed: }
Execution Count:34
34
28 return tld;
executed: return tld;
Execution Count:9
9
29} -
30 -
31 -
32 -
33 -
34 -
35 -
36 -
37__attribute__((visibility("default"))) bool qIsEffectiveTLD(const QString &domain) -
38{ -
39 -
40 -
41 if (containsTLDEntry(domain))
evaluated: containsTLDEntry(domain)
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:256
16-256
42 return true;
executed: return true;
Execution Count:16
16
43 -
44 if (domain.contains(QLatin1Char('.'))) {
evaluated: domain.contains(QLatin1Char('.'))
TRUEFALSE
yes
Evaluation Count:255
yes
Evaluation Count:1
1-255
45 int count = domain.size() - domain.indexOf(QLatin1Char('.')); -
46 QString wildCardDomain; -
47 wildCardDomain.reserve(count + 1); -
48 wildCardDomain.append(QLatin1Char('*')); -
49 wildCardDomain.append(domain.right(count)); -
50 -
51 -
52 if (containsTLDEntry(wildCardDomain)) {
evaluated: containsTLDEntry(wildCardDomain)
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:248
7-248
53 QString exceptionDomain; -
54 exceptionDomain.reserve(domain.size() + 1); -
55 exceptionDomain.append(QLatin1Char('!')); -
56 exceptionDomain.append(domain); -
57 return (! containsTLDEntry(exceptionDomain));
executed: return (! containsTLDEntry(exceptionDomain));
Execution Count:7
7
58 } -
59 }
executed: }
Execution Count:248
248
60 return false;
executed: return false;
Execution Count:249
249
61} -
62 -
63 -
64 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial