diff options
author | Peter Hartmann <phartmann@rim.com> | 2013-02-08 17:48:05 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-09 10:12:44 +0100 |
commit | 916f0ff663f7915387085911ceb7e2c704833e4f (patch) | |
tree | 96aa7d1835af3795646f28e7ed59674226a00cec /src/corelib/io/qtldurl.cpp | |
parent | 2e9caa8942a2c4938385960c6b92dee629e78922 (diff) |
QUrl effective TLDs: update table and split into chunks of 64K
The table is there to know which domains are allowed to set cookies
and which are not. There are more than 2000 new entries since the
list has last been generated.
The split to 64K chunks was made because this is the hard limit for
strings in Visual Studio.
Change-Id: I511aec062af673555e9a69442c055f75bdcd1606
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qtldurl.cpp')
-rw-r--r-- | src/corelib/io/qtldurl.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/corelib/io/qtldurl.cpp b/src/corelib/io/qtldurl.cpp index 436e6a4568..dd4301e9f1 100644 --- a/src/corelib/io/qtldurl.cpp +++ b/src/corelib/io/qtldurl.cpp @@ -51,12 +51,22 @@ QT_BEGIN_NAMESPACE static bool containsTLDEntry(const QString &entry) { int index = qt_hash(entry) % tldCount; - int currentDomainIndex = tldIndices[index]; - while (currentDomainIndex < tldIndices[index+1]) { - QString currentEntry = QString::fromUtf8(tldData + currentDomainIndex); + + // select the right chunk from the big table + short chunk = 0; + uint chunkIndex = tldIndices[index], offset = 0; + while (tldIndices[index] >= tldChunks[chunk] && chunk < tldChunkCount) { + chunkIndex -= tldChunks[chunk]; + offset += tldChunks[chunk]; + chunk++; + } + + // check all the entries from the given index + while (chunkIndex < tldIndices[index+1] - offset) { + QString currentEntry = QString::fromUtf8(tldData[chunk] + chunkIndex); if (currentEntry == entry) return true; - currentDomainIndex += qstrlen(tldData + currentDomainIndex) + 1; // +1 for the ending \0 + chunkIndex += qstrlen(tldData[chunk] + chunkIndex) + 1; // +1 for the ending \0 } return false; } |