Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/io/qtldurl.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | static bool containsTLDEntry(const QStringRef &entry) | - | ||||||||||||
5 | { | - | ||||||||||||
6 | int index = qt_hash(entry) % tldCount; | - | ||||||||||||
7 | - | |||||||||||||
8 | - | |||||||||||||
9 | short chunk = 0; | - | ||||||||||||
10 | uint chunkIndex = tldIndices[index], offset = 0; | - | ||||||||||||
11 | while (chunk < tldChunkCount
| 0-899 | ||||||||||||
12 | chunkIndex -= tldChunks[chunk]; | - | ||||||||||||
13 | offset += tldChunks[chunk]; | - | ||||||||||||
14 | chunk++; | - | ||||||||||||
15 | } executed 135 times by 3 tests: end of block Executed by:
| 135 | ||||||||||||
16 | - | |||||||||||||
17 | - | |||||||||||||
18 | while (chunkIndex < tldIndices[index+1] - offset
| 640-656 | ||||||||||||
19 | QString currentEntry = QString::fromUtf8(tldData[chunk] + chunkIndex); | - | ||||||||||||
20 | if (currentEntry == entry
| 108-532 | ||||||||||||
21 | return executed 108 times by 2 tests: true;return true; Executed by:
executed 108 times by 2 tests: return true; Executed by:
| 108 | ||||||||||||
22 | chunkIndex += qstrlen(tldData[chunk] + chunkIndex) + 1; | - | ||||||||||||
23 | } executed 532 times by 3 tests: end of block Executed by:
| 532 | ||||||||||||
24 | return executed 656 times by 3 tests: false;return false; Executed by:
executed 656 times by 3 tests: return false; Executed by:
| 656 | ||||||||||||
25 | } | - | ||||||||||||
26 | - | |||||||||||||
27 | static inline bool containsTLDEntry(const QString &entry) | - | ||||||||||||
28 | { | - | ||||||||||||
29 | return executed 336 times by 3 tests: containsTLDEntry(QStringRef(&entry));return containsTLDEntry(QStringRef(&entry)); Executed by:
executed 336 times by 3 tests: return containsTLDEntry(QStringRef(&entry)); Executed by:
| 336 | ||||||||||||
30 | } | - | ||||||||||||
31 | __attribute__((visibility("default"))) QString qTopLevelDomain(const QString &domain) | - | ||||||||||||
32 | { | - | ||||||||||||
33 | const QString domainLower = domain.toLower(); | - | ||||||||||||
34 | QVector<QStringRef> sections = domainLower.splitRef(QLatin1Char('.'), QString::SkipEmptyParts); | - | ||||||||||||
35 | if (sections.isEmpty()
| 0-36 | ||||||||||||
36 | return never executed: QString();return QString(); never executed: return QString(); | 0 | ||||||||||||
37 | - | |||||||||||||
38 | QString level, tld; | - | ||||||||||||
39 | for (int j = sections.count() - 1; j >= 0
| 36-136 | ||||||||||||
40 | level.prepend(QLatin1Char('.') + sections.at(j)); | - | ||||||||||||
41 | if (qIsEffectiveTLD(level.rightRef(level.size() - 1))
| 62-74 | ||||||||||||
42 | tld = level; executed 74 times by 1 test: tld = level; Executed by:
| 74 | ||||||||||||
43 | } executed 136 times by 1 test: end of block Executed by:
| 136 | ||||||||||||
44 | return executed 36 times by 1 test: tld;return tld; Executed by:
executed 36 times by 1 test: return tld; Executed by:
| 36 | ||||||||||||
45 | } | - | ||||||||||||
46 | - | |||||||||||||
47 | - | |||||||||||||
48 | - | |||||||||||||
49 | - | |||||||||||||
50 | - | |||||||||||||
51 | - | |||||||||||||
52 | - | |||||||||||||
53 | __attribute__((visibility("default"))) bool qIsEffectiveTLD(const QStringRef &domain) | - | ||||||||||||
54 | { | - | ||||||||||||
55 | - | |||||||||||||
56 | - | |||||||||||||
57 | if (containsTLDEntry(domain)
| 98-330 | ||||||||||||
58 | return executed 98 times by 2 tests: true;return true; Executed by:
executed 98 times by 2 tests: return true; Executed by:
| 98 | ||||||||||||
59 | - | |||||||||||||
60 | const int dot = domain.indexOf(QLatin1Char('.')); | - | ||||||||||||
61 | if (dot >= 0
| 3-327 | ||||||||||||
62 | int count = domain.size() - dot; | - | ||||||||||||
63 | QString wildCardDomain = QLatin1Char('*') + domain.right(count); | - | ||||||||||||
64 | - | |||||||||||||
65 | - | |||||||||||||
66 | if (containsTLDEntry(wildCardDomain)
| 9-318 | ||||||||||||
67 | QString exceptionDomain = QLatin1Char('!') + domain; | - | ||||||||||||
68 | return executed 9 times by 1 test: (! containsTLDEntry(exceptionDomain));return (! containsTLDEntry(exceptionDomain)); Executed by:
executed 9 times by 1 test: return (! containsTLDEntry(exceptionDomain)); Executed by:
| 9 | ||||||||||||
69 | } | - | ||||||||||||
70 | } executed 318 times by 3 tests: end of block Executed by:
| 318 | ||||||||||||
71 | return executed 321 times by 3 tests: false;return false; Executed by:
executed 321 times by 3 tests: return false; Executed by:
| 321 | ||||||||||||
72 | } | - | ||||||||||||
73 | - | |||||||||||||
74 | - | |||||||||||||
Switch to Source code | Preprocessed file |