summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qurlidna.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Try to workaround bogus compiler warning in gcc 9 for ARMv7Lars Knoll2020-07-061-2/+1
| | | | | | | | | | | | | | | | | | | | | | | ../../src/corelib/io/qurlidna.cpp: In function ‘QString qt_ACE_do(QStringView, AceOperation, AceLeadingDot)’: ../../src/corelib/io/qurlidna.cpp:2543:23: error: ‘int __builtin_memcmp_eq(const void*, const void*, unsigned int)’ reading 8 bytes from a region of size 2 [-Werror=stringop-overflow=] if (memcmp(result.constData() + prevLen, acePrefixUtf16, sizeof acePrefixUtf16) == 0) ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1plus: all warnings being treated as errors In function ‘bool operator==(const QByteArray&, const QByteArray&)’, inlined from ‘virtual void (* QLinuxFbIntegration::platformFunction(const QByteArray&) const)()’ at ../../src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp:185:18: include/QtCore/../../../../src/corelib/text/qbytearray.h:571:45: error: ‘int __builtin_memcmp_eq(const void*, const void*, unsigned int)’ reading 17 bytes from a region of size 1 [-Werror=stringop-overflow=] The warnings/errors are bogus. Fix them by using QStringView::sliced() and de-inlining the comparison operator for QByteArray. Change-Id: I24956fe74a7989e75cd03d717570b8fca493ab23 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port QString to qsizetypeLars Knoll2020-07-061-1/+1
| | | | | | Change-Id: Id9477ccfabadd578546bb265a9483f128efb6736 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add a note to qurlidna.cpp about IDNA's Unicode version being frozenEdward Welbourne2020-07-021-0/+9
| | | | | | | | | | | | It looked a lot like it needed an update to its Unicode data (in tables and functions) but Thiago tells me this would be misguided, although we do need an upgrade to IDNA 2008, at some point. So document why this doesn't get updated along with UCD. Task-number: QTBUG-85371 Task-number: QTBUG-85323 Change-Id: I764667db9c24bf05371e8a3c2601ccbf48f99711 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QUrl: do not retest if a codepoint is less than 0xFFFFGiuseppe D'Angelo2020-06-301-1/+1
| | | | | | | It's already tested in the surrounding if. Change-Id: I37e13406cfd4865731ce06ed097c03294a75c592 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrlIdna: port containsProhibitedOutput() to QStringIteratorMarc Mutz2020-05-131-21/+22
| | | | | | | | | | | | | | | | | | Also Extract Method isProhibitedOutput(), which, in order to preserve history, is placed in the unnamed namespace and violates the indentation rules. But this code is delicate enough to be left undisturbed. At least for now. By said Extract Method, we can static_assert on the invalidity of the QStringIterator::next() argument, which we assume will be rejected, so that we continue to reject malformed surrogate pairs. Also fix a comment that suggested the function would actively remove ("strip") malformed content, when in fact it only detects it. Change-Id: I4185cbac71fb147e2f2036dbaf052af20bd1003f Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrlIdna: port NameprepCaseFoldingEntry from int-ish to char-ishMarc Mutz2020-05-131-4/+4
| | | | | Change-Id: I43171aae8188cc68d9c03716451c6427486cc55c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QUrlIdna: replace manual pointer handling with std::begin()/end()Marc Mutz2020-05-131-6/+4
| | | | | | | This is more readable, because it follows usual iterator patterns. Change-Id: I56900286ddbca57a86aa499020f175e8add17fd9 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Port qt_punycodeEncoder() to QStringViewMarc Mutz2020-05-131-15/+13
| | | | | Change-Id: I264e67bc08413f8a39e2d16c774bfd2c76c320ac Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Port qt_check_std3rules() to QStringViewMarc Mutz2020-05-131-12/+14
| | | | | | | Also port its callees. These functions scream to the QStringView-ified... Change-Id: I13c95d65941eb8d02223306d80efd1437b4bd9b7 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QUrlIdna: QChar(0x2d) → QLatin1Char('-')Marc Mutz2020-05-121-2/+2
| | | | | | | | A reader of the code shoudn't need to know ASCII code points by heart, so don't force them to. Change-Id: I2c44fcf4a948b85dfbc02ac8b5b7b934e87b41a7 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Cache QUrl::idnWhiteList() absent user_idn_whitelistMarc Mutz2020-05-121-7/+10
| | | | | | | | | | | | Instead of creating a QStringList from a static array anew for each call, cache the result in a static variable. If we have to pay for the overhead of implicitly-shared classes, we should at least reap the benefits, too. Use IILE to gain automatic thread-safety (thread-safe statics). Change-Id: Ib92dd9cb85f84e013f98ca81565cc392bb39e76b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QUrlIdna: simplify a loop using QStringView::mid()Marc Mutz2020-05-051-6/+4
| | | | | | Change-Id: I0f33a29b3104ceac4c5dfb9db2bfdcd896bb95d1 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QUrlIdna: avoid QString creationMarc Mutz2020-05-021-3/+2
| | | | | | | Change-Id: Id05eecfcb1e170920c05fb0c7f17e46f039b4dee Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrlIdna: port qt_ACE_do() to QStringViewMarc Mutz2020-05-021-3/+3
| | | | | | | Change-Id: I29abc17576ceb72dd678e3ca59456e6220acd0a6 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrlIdna: port nextDotDelimiter() to QStringViewMarc Mutz2020-05-021-7/+6
| | | | | Change-Id: I4fec88be2dacadcbb72927b973a51e1ead178c88 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrlIdna: port qt_is_idn_enabed() to QStringViewMarc Mutz2020-04-241-3/+3
| | | | | | Change-Id: I3cd8a1da47f660f79760bbde88560693ab505823 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QUrlIdna: re-enable NRVOMarc Mutz2020-04-241-2/+2
| | | | | Change-Id: Id4f9b14f4255c661a0313ca18b0c5af5c55880e7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Be less laissez-faire with implicit conversions to QCharMarc Mutz2019-07-091-3/+2
| | | | | | | | | | | | | QChar currently is convertible from nearly every integral type. This is bad code hygiene and should be fixed come Qt 6. The present patch is the result of compile fixes from marking these constructors explicit. As is clear from the distribution of fixes, only low-level string handling code used these implicit conversions, an indication that they're not in widespread use elsewhere. Change-Id: Ief5336f21e6d181e03ab92893b3d13a14adc7cb0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Move away from using 0 as a pointer constantAllan Sandfeld Jensen2019-06-071-3/+3
| | | | | | | | | Cleans up most of corelib to use nullptr or default enums where appropriate. Change-Id: Ifcaac14ecdaaee730f87f10941db3ce407d71ef9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrl: Make sure we do reject URLs for which IDNA nameprep failedThiago Macieira2018-08-161-6/+11
| | | | | | | | | | | | | | qt_nameprep() already reset the string to its original length to indicate failure, but we didn't handle that in qt_ACE_do(). So make it have a return value whcih makes it easier to handle that case and do handle it. [ChangeLog][QtCore][QUrl] Fixed a bug that caused URLs whose hostnames contained unassigned or prohibited Unicode codepoints to report isValid() = true, despite clearing the hostname. Change-Id: I41e7b3bced5944239f41fffd1545b7274c4b419d Reviewed-by: David Faure <david.faure@kdab.com>
* QtCore: Raise minimum supported MSVC version to 2015Friedemann Kleint2018-01-081-5/+0
| | | | | | | | Remove code for older versions and streamline #ifdefs. Task-number: QTBUG-51673 Change-Id: I211703189ff12f827d94914093369736b6e65d4a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrl: fix IDN conversion when the ACE form is invalidThiago Macieira2017-04-251-9/+36
| | | | | | | | | | | | | | | | We guarded against the Unicode form being invalid and did not produce an encoded form. But we did not guard against proper Punycode sequences that decode to forms that had not passed the proper Nameprep stage. So check for that and, if it fails, just keep the label in the form we found it in (it's valid STD3 anyway). [ChangeLog][QtCore][QUrl] Fixed a bug that caused certain domain names that look like Internationalized Domain Names to become corrupt in decoded forms of QUrl, notably toString() and toDisplayString(). Task-number: QTBUG-60364 Change-Id: Iadfecb6f28984634979dfffd14b833142cca8d0d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QUrl: fix IDN whitelist checking when the TLD is in UnicodeThiago Macieira2017-04-241-2/+2
| | | | | | | | | | The whitelist is kept in ACE form, so if the TLD came in Unicode, we need to run ToASCII before we can check the whitelist. This is slightly inefficient because we'll run the same operation later in this domain. Change-Id: Iadfecb6f28984634979dfffd14b831f37b0f4818 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Florian Bruhin <qt-project.org@the-compiler.org>
* Use QStringLiteral more judiciouslyAnton Kudryavtsev2016-07-081-1/+1
| | | | | | | | | | | | | | | Replace it with QL1S in QStringBuilder expressions and in overloaded functions. Replace patterns 'QString::number() + QStringLiteral' and 'QStringLiteral + QString::number()' with QString::asprintf. Saves some text size. Change-Id: Ib39b2332264dfc3df04e77f2c101b47a1030cef4 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add Intel copyright to files that Intel has had non-trivial contributionThiago Macieira2016-01-211-0/+1
| | | | | | | | | I wrote a script to help find the files, but I reviewed the contributions manually to be sure I wasn't claiming copyright for search & replace, adding Q_DECL_NOTHROW or adding "We mean it" headers. Change-Id: I7a9e11d7b64a4cc78e24ffff142b506368fc8842 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Fix some -Wcast-qual warningsThiago Macieira2015-09-221-1/+1
| | | | | | | | | | | This is happening in code I don't usually test (32-bit, non-ICU, etc.) KeccakF-1600-opt32.c:481:22: error: cast from type 'const unsigned char*' to type 'UINT32* {aka unsigned int*}' casts away qualifiers [-Werror=cast-qual] KeccakF-1600-opt32.c:217:62: note: in definition of macro 'extractLanes' Change-Id: I42e7ef1a481840699a8dffff140209823301a07a Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com> Reviewed-by: Richard J. Moore <rich@kde.org>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2014-02-121-1/+1
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/gui/image/qimage.cpp src/gui/text/qtextengine.cpp src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp src/printsupport/kernel/qprintengine_win.cpp Change-Id: I09ce991a57f39bc7b1ad6978d0e0d858df0cd444
| * Small doc fix.Niels Weber2014-02-071-1/+1
| | | | | | | | | | Change-Id: If700cce1b39342ca2b1027e2c10711ea45c3dd9c Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
* | expand tabs and related whitespace fixes in *.{cpp,h,qdoc}Oswald Buddenhagen2014-01-131-1/+1
|/ | | | | | | | the diff -w for this commit is empty. Started-by: Thiago Macieira <thiago.macieira@intel.com> Change-Id: I77bb84e71c63ce75e0709e5b94bee18e3ce6ab9e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix WinCE/MSVC2008 build errors related to std::lower_bound patches.Sérgio Martins2013-09-251-0/+5
| | | | | | | See QTBUG-33473 for more information about this compiler bug. Change-Id: I13b945350fdc38165c1515f0cdd75a53cf37cd6c Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Remove qBinaryFind usages from QtCoreGiuseppe D'Angelo2013-09-231-4/+5
| | | | | | | | This is done per the mailing list discussion at http://www.mail-archive.com/development@qt-project.org/msg01603.html Change-Id: I6207982c08c92f3e01fb236d2e7546a1c9acd287 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Fix QUrl::topLevelDomain(QUrl::FullyDecoded)David Faure2013-07-061-2/+3
| | | | | | | | | qt_ACE_do(".co.uk") was returning an empty string because of the leading dot. Allow leading dots from topLevelDomain, but not from other calls. Change-Id: I757d9960708e205d30554cd2bbcf618c8624792b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Revert "Fix QUrl::topLevelDomain(QUrl::FullyDecoded)"Thiago Macieira2013-07-021-2/+1
| | | | | | | | | | This reverts commit e3fa266623b08e837cb4ccc7fe59da243d03dd27 That commit applied a change at the wrong place in the code. Change-Id: I21e3045a3af14ad2f90c5fe338815c35a2d27ae6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: David Faure (KDE) <faure@kde.org>
* Fix QUrl::topLevelDomain(QUrl::FullyDecoded)David Faure2013-07-011-1/+2
| | | | | | | | | qt_ACE_do(".co.uk") was returning an empty string because of the leading dot. This has always caused issues in KDE code too, where ACE normalization needs the dot removed, and re-added afterwards. Change-Id: Id9fcea0333cf55c14d755a86d4bf33a50f194429 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
* Remove use of 'register' from Qt.Stephen Kelly2013-06-171-4/+4
| | | | | | | | | | It is deprecated and clang is starting to warn about it. Patch mostly generated by clang itself, with some careful grep and sed for the platform-specific parts. Change-Id: I8058e6db0f1b41b33a9e8f17a712739159982450 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrl stringprep: fix handling of U+0080: it's prohibitedThiago Macieira2013-06-081-1/+1
| | | | | | | | Edge case: a > that should have been >=. Without it, we never ran the rest of the IDN nameprepping. Change-Id: I2276d660de3a70d0c561bb18816820d9a0f47e77 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* QUrl stringprep: avoid recalculating the surrogates we already knowThiago Macieira2013-06-081-2/+2
| | | | | Change-Id: Icac4e81fff6f7f7fa4f46ec2a08105f8d3d2b403 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* QUrl stringprep: fix handling of prohibited charactersThiago Macieira2013-06-081-11/+14
| | | | | | | | | | | | | | | | | | | | RFC 3454 says about prohibited characters (section 2, "Preparation Overview"): 3) Prohibit -- Check for any characters that are not allowed in the output. If any are found, return an error. This is described in section 5. In other words, we mustn't simply strip the output of prohibited characters. We must generate an error if they are present. We do that by clearing the data. We already had tests for prohibited output, but they were indistinguishable from being stripped. So instead add some extra characters so that we can tell whether the label was cleared. Change-Id: I2d95217c27be5e2d54deed0036cb009e3b7f4886 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* QUrl stringprep: fix case folding from non-BMP to BMPThiago Macieira2013-06-081-1/+1
| | | | | | | | | | | | When uc > 0xffff (non-BMP character) and l == 1 (replacement is in the BMP), we must use QString::replace so the correct number of characters is replaced. There's one case testing this in tst_qurlinternal, but it is being obscured by another bug (false positive). Change-Id: I32388dd5bef32d4d6804aeeec4904bd5f563e9b9 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* QUrl stringprep: recalculate the current position if the size changesThiago Macieira2013-06-081-1/+2
| | | | | | | | | | | | | If the case folding operation results in either expansion or reduction of the string, we need to adapt. Reduction happens most often when a non-BMP character is case-folded to a character in the BMP (example: mathematical signs at U+1D400-1D7FF). Expansion happens in the rare case of symbols containing words, like U+2121 ℡ (this is part of the unit test), and one common case: the German sharp S (ß) is expanded to "ss". Change-Id: I1bdbdc908b958a89bf30e4bb648d65dfdd9097f8 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* QUrl: update top level domains that may contain non-ASCII charactersPeter Hartmann2013-03-021-7/+22
| | | | | | | | | Most notably, .com and .net now may contain non-ASCII characters. list has been generated from http://www.mozilla.org/projects/security/tld-idn-policy-list.html Change-Id: Idc3191dc782bc4173ccb19b4bc81f4f061ca7999 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Fix a couple of qdoc errorsLars Knoll2012-08-181-1/+1
| | | | | Change-Id: I79f689e08ed4a496052529af38fca72c3d4e04cb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrl::idnWhiteList(): add QList::reserve() callMarc Mutz2012-08-071-2/+4
| | | | | | | | Avoids reallocation. Change-Id: I3238574590463596a797d237b066ef60214392a7 Reviewed-by: David Faure <faure@kde.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrl: document that setIdnWhitelist isn't thread-safeMarc Mutz2012-07-301-0/+3
| | | | | | | This is a forward-port of 6b10fc91 from Qt 4. Change-Id: I58878bf24e4f1b50ebfd0457c37eef58696f4a4c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add some missing includes.Stephen Kelly2012-05-031-0/+2
| | | | | | | | There is a #include <QStringList> line wrapped in QT_DEPRECATED_SINCE(5, 0). Change-Id: I766848dfcc3bd765c57626a3d70f492ac1219091 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>