summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qurl.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-01-221-1/+1
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qsavefile_p.h src/corelib/tools/qregularexpression.cpp src/gui/util/qvalidator.cpp src/gui/util/qvalidator.h Change-Id: I58fdf0358bd86e2fad5d9ad0556f3d3f1f535825
| * Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | | | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | QUrl: methods for converting QStringList <-> QList<QUrl>David Faure2013-01-141-0/+31
|/ | | | | | | This is a very common thing to do, e.g. in order to send urls via DBus. Change-Id: I277902460ee1ad6780446e862e86b3c2eb8c5315 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrl::fromUserInput: fix for urls without a host.David Faure2012-12-231-2/+1
| | | | | | | | | | QUrl::fromUserInput("http://") was invalid, which doesn't make sense since QUrl("http://") is valid. Same for "smb:" which is actually even more a valid URL from a user's point of view. Change-Id: I371ac393d61b49499edf5adbbc2a90b426fe9e5d Reviewed-by: Marco Martin <mart@kde.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use the new QUrlPrivate::validateComponent validator in the main parserThiago Macieira2012-12-211-54/+11
| | | | | | | | The code was copied from the main parser there, so remove the duplication. Change-Id: I85748f6f76b3097ff22958d9de67cfa27061a72b Reviewed-by: David Faure (KDE) <faure@kde.org>
* Make sure that the strict parser is also operating on setXxxThiago Macieira2012-12-211-43/+136
| | | | | | | | | | | These cases weren't handled before. The validateComponent function is copied from QUrlPrivate::parse, with the added modification that it now needs to check the gen-delims for the userinfo. Change-Id: I055167b977199fa86b56a3a7259a7445585129c6 Reviewed-by: David Faure (KDE) <faure@kde.org>
* Fix some typosSergio Ahumada2012-12-211-1/+1
| | | | | Change-Id: I4e8d9bd8ea66ec810e4f1fbfd8ddbf25c4b3d980 Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
* Change ftp.qt.nokia.com -> ftp.qt-project.orgSergio Ahumada2012-12-181-1/+1
| | | | | | Task-number: QTBUG-28156 Change-Id: I0060144f0336791933205355b125251ccba73b3e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: refer to QUrlQuery in QUrl's main doc bodyThiago Macieira2012-10-191-3/+4
| | | | | | | | As opposed to the deprecated methods. Task-number: QTBUG-25628 Change-Id: Ic1b50b1ac1b974cdd2dd9f0151d567227784e547 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* Overhaul a little the QUrl error reporting.Thiago Macieira2012-10-021-95/+173
| | | | | | | | | | | | | | | | | | | | | | Keep the original QString that triggered the parsing error, instead of just one QChar. This provides more powerful error messages, like: Invalid IPv6 address; source was "http://[:::]"; scheme = "http", host = "" (QUrl cannot keep invalid hostnames) Invalid port or port number out of range; source was "http://example.com:abc"; scheme = "http", host = "example.com" (QUrl cannot keep a non-numeric port number) Invalid path (character '%' not permitted); source was "foo:/path%?"; scheme = "foo", path = "/path%25%1F" (the tolerant parser runs first, so the faulty component is fixed) This stores the error state in a special structure which is not allocated under normal conditions, keeping the memory consumption down. On 32-bit systems, QUrlPrivate does not increase in size; on 64-bit systems, it grows by 8 bytes. Change-Id: I93d798d43401dfeb9fca7b6eed7ea758da10136b Reviewed-by: David Faure <faure@kde.org>
* Update some error messages in QUrl::errorString()Thiago Macieira2012-10-021-2/+3
| | | | | | | | | Make both invalid hostname messages start with "Invalid hostname". And split the empty port error from the invalid port one. Change-Id: I870d1ed6fb07ec494f553871a37ed167141ffc06 Reviewed-by: David Faure <faure@kde.org> Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
* Add Q_UNREACHABLE / Q_ASSERT to two conditions that can't happenThiago Macieira2012-10-021-1/+7
| | | | | | | | Just so the code generation is a little better. Change-Id: I2a43a4df0ae67900c465a6c2b4f2b8ba284dbbaa Reviewed-by: Shane Kearns <shane.kearns@accenture.com> Reviewed-by: David Faure <faure@kde.org>
* Move QUrlPrivate to qurl.cpp and mark all methods as inlineThiago Macieira2012-10-021-9/+125
| | | | | | | | | | They're never accessed outside of qurl.cpp anyway, so let the compiler know that it doesn't need to generate a full out-of-line copy for them in case it does inlining. Change-Id: I2be069b3fd2658eff9ad3023c21c8ae653c389ab Reviewed-by: Shane Kearns <shane.kearns@accenture.com> Reviewed-by: David Faure <faure@kde.org>
* Change QUrlPrivate::setAuthority to return voidThiago Macieira2012-10-021-3/+3
| | | | | | | | | | | | | It used to return bool because setHost returns bool and, therefore, setAuthority could fail. However, the return value is never checked, in either parse() or QUrl::setAuthority(), because there's no error recovery. This is a small optimisation. Change-Id: I25660d66cfad64ca5b9706cc38afa0e97ba3ee0b Reviewed-by: Shane Kearns <shane.kearns@accenture.com> Reviewed-by: David Faure <faure@kde.org>
* Remove the annoying qWarning when QUrl::setPort is out of rangeThiago Macieira2012-10-021-1/+0
| | | | | | | | | | That's what we have QUrl::errorString() for. This will become evident especially now that QUrl::toString() / toEncoded() return empty if there are errors. Change-Id: I64a84e9c6ee57c0fc38cc0c58f5286ddc1248d1f Reviewed-by: Shane Kearns <shane.kearns@accenture.com> Reviewed-by: David Faure <faure@kde.org>
* Update QUrlPrivate::setScheme: EmptySchemeError never happensThiago Macieira2012-10-021-7/+5
| | | | | | | | | | | | | | | As the comment says, an empty scheme is not permitted. However, if that error were to happen, QUrl falls back to parsing the URI as an "URI reference", starting with the path. E.g., ":/foo" is a path of ":/foo", which will in turn trigger the compound "colon before slash" error. Also, we don't percent-decode in the scheme. Change-Id: I438a61e17323c7722ddcc64792577a9ecb869c4b Reviewed-by: Shane Kearns <shane.kearns@accenture.com> Reviewed-by: David Faure <faure@kde.org>
* Make QUrl::errorString() usable for QtTest output in invalid URLsThiago Macieira2012-10-021-21/+54
| | | | | | | | | If an URL is invalid, let's indicate that in the test output. To be helpful, let's make QUrl::errorString() include the component form of the URL. Change-Id: Iaafe16973ded79c7ea688fbb23808d91253e8c14 Reviewed-by: David Faure <faure@kde.org>
* Make QUrl::toString() / toEncoded() return empty for invalid URLsThiago Macieira2012-10-021-5/+4
| | | | | Change-Id: I6ebb4ad2901a9bacb09fb81082202f37ebbc2e97 Reviewed-by: David Faure <faure@kde.org>
* Add two compound URL invalidity cases for isValid()Thiago Macieira2012-10-021-12/+53
| | | | | | | | | | | | | | These two errors can only happen if one calls setPath() explicitly. They cannot happen for parsed URLs, which is why they are only caught with isValid(). It's not possible to set the error condition in setPath() either because they depend on the presence / absence of the authority and scheme. Also update all the unit tests that set a path not starting with a slash and were just "freeloaders" on the previous behaviour. Change-Id: Ice58cd4589a850452d7573a5b19667bbab2fb43e Reviewed-by: David Faure <faure@kde.org>
* 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>
* QUrl: port thread-safety autotest from Qt4.David Faure2012-08-261-0/+2
| | | | | | | | This detected the same missing detach()s in QUrl::resolve. Everything else works, no need for a mutex in Qt5's QUrl. Change-Id: I0da51b7b0c6b810d314a26d4b638383cd17de12b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Add \inmodule QtCore to all QtCore class doc bodiesThiago Macieira2012-08-231-0/+1
| | | | | Change-Id: I19100755c97cc155c76a859e19940e9f9222d34e Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Fix decoding of QByteArray in the deprecated "encoded" setters in QUrlThiago Macieira2012-08-201-0/+11
| | | | | | | | | | | | | | The asymmetry is intentional: the getters can use toLatin1() because the called functions, with a QUrl::FullyEncoded parameter, return ASCII only. This gives a small performance improvement over the need to run the UTF-8 encoder. However, the data passed to setters could contain non-ASCII binary data, in addition to the percent-encoded data. We can't use fromUtf8 because it's binary and we can't use toPercentEncoded because it already encoded. Change-Id: I5ecdb49be5af51ac86fd9764eb3a6aa96385f512 Reviewed-by: David Faure <faure@kde.org>
* Add Q_DECL_NOTHROW to some qHash functionsThiago Macieira2012-08-201-1/+1
| | | | | | | | | | | | The hashing functions for QDateTime and QHostAddress did not get the noexcept keyword because they might allocate memory. QDateTime doesn't do it now, but it could in the future. QHostAddress does allocate memory today. Change-Id: Ia5f80942944bfc2b8c405306c467bfd88ef0e48c Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Misc documentation fixes triggered by qdoc errors/warningsShawn Rutledge2012-08-201-5/+4
| | | | | Change-Id: I6ca3b138114fe957a09e8ec2f22273865635fc8b Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
* Modernise, update and fix errors in the QUrl documentationThiago Macieira2012-08-181-44/+65
| | | | | | | | | | | | | | Update the documentation of the deprecated API to match the current behaviour. Notably, the current behaviour is to check the correctness of the percent-encoding even in the "encoded" functions. Also, the use of QUrlQuery makes the matching work on canonical forms, so "%73earch" does match "search". Elsewhere, make sure we do not refer to the deprecated API in the documentation of non-deprecated functions. Change-Id: If3505ac3c6121177ad6ab18199e143775bef44b9 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Bring back the documentation on QUrl deprecated methodsThiago Macieira2012-08-181-0/+433
| | | | | | | | | | | | | | | | The deprecated query methods were removed along with their documentation in commit 1c2144c39fa0069bf496e8f77389a9c2f8a31acf, so restore it from before that commit. The rest of the encoded methods were removed along with their documentation in commit 1372d60bde04a31c8036601076d1093a67c6bd46. Restore their documentation from the previous commit to that one. All the documentation from this commit is brought back unchanged, except for the addition of \deprecated. Change-Id: I1851b0dc922c681e1623359b35dfd0f505d258d2 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Fix a couple of qdoc errorsLars Knoll2012-08-181-1/+1
| | | | | Change-Id: I79f689e08ed4a496052529af38fca72c3d4e04cb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make the "\internal" qdoc command stand on its own lineLaszlo Papp2012-08-151-1/+2
| | | | | | | | | | The qdoc manual currently claims that the command must stand on its own line. The change follows the consistency with the rest and how the example looks like inside the qdoc manual for this command. Change-Id: I6b653dc95cf9d84e4adf32220dace5d313678419 Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Make sure that the parsing mode reaches QUrlPrivate::setHostThiago Macieira2012-08-011-9/+9
| | | | | | | | | | | | Ensure that the parsing mode is cascaded down from setAuthority and setUrl so that the hostname parsing does not attempt to decode percent-encoded hostnames when it shouldn't. Take the opportunity to also remove the "Boolean Trap" from QUrlPrivate::setHost. Change-Id: Ia64754c4a4900182700b7af1382aea8410abc7e9 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Make QUrl::setScheme only parse in strict mode (no decoding)Thiago Macieira2012-08-011-15/+2
| | | | | | | | | | The URI RFC defines schemes as containing only a very restricted set of characters, none of which require encoding, so don't even try. Testing this behaviour in some web browsers indicate that they do not accept percent-encoded schemes either. Change-Id: I692dd20e1aac7e8a1bcb276cb5113b5802393d38 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Fix QUrl support for empty usernames and passwordsThiago Macieira2012-08-011-1/+1
| | | | | | | | | | | | | | | If the password is empty (but present), the userinfo component of the URL should end in a colon (":"). QUrl already supported that and it was tested (case "password-empty"). If the username is *also* empty but present, the userinfo component is just the colon (":"). Fix support for that case by checking if we stored the presence flag instead of checking the size of the component. Change-Id: Ie224493a997dbf76b2e44dd6d55fd9674ac83c1c Reviewed-by: David Faure <faure@kde.org> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Fix handling of encoded NULs (%00) in QUrl::fromPercentEncodingThiago Macieira2012-08-011-1/+2
| | | | | | | | | | | | | QString::fromUtf8, without an explicit size, (currently) defaults to stopping at the first NUL. That means we need to pass an explicit size. Also take the opportunity to test that QUrl::toPercentEncoding also works with the same data. Change-Id: I79362d67afda624b01ca07b0315b611c4aa3fdda Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: David Faure <faure@kde.org>
* Fix several QUrl qdoc errorsJeremy Katz2012-07-261-6/+11
| | | | | Change-Id: I2b89751ed2ec54f3b992c5fc4b39539d521c3404 Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Doc: Fix QUrl::isLocalFile documentationSergio Ahumada2012-07-201-1/+1
| | | | | | | | | | This function was introduced in 4.7 by a2f797b52c4274a62a7cf1f0939aca1429afe211 but then reverted by 98e935eed5549e479f6666680aed1711dc42111c Task-number: QTBUG-21293 Change-Id: I6ec9c6696e5c85e44774184010eb9135ef7f3365 Reviewed-by: David Faure <faure@kde.org> Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Ensure that no extra bits can leak into QUrl::toEncoded.Thiago Macieira2012-06-241-1/+1
| | | | | | | | | | Technically, this function should take QUrl::UrlFormattingOptions, but that doesn't exist. So we just mask out the high bits that determine the encoding options. toEncoded only supports one encoding way: fully encoded. Change-Id: I1445ad7c292500921ec2672be4524d7d76a39f98 Reviewed-by: David Faure <faure@kde.org>
* Make qurlinfo private, now that QFtp is private.David Faure2012-06-141-2/+0
| | | | | | Change-Id: I0bb641b397b7087c89009f92d9973e0922dce653 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
* Fix QUrl documentation: FullyDecoded and DecodedMode are a pairThiago Macieira2012-06-141-4/+4
| | | | | | | DecodedMode with FullyEncoded makes no sense whatsoever. Change-Id: I182db7aceb38e4e9398138066022912adec9c413 Reviewed-by: David Faure <faure@kde.org>
* QtCore: remove \link usagesGiuseppe D'Angelo2012-05-291-2/+2
| | | | | Change-Id: I0de764b51a972de0b6eb2bf3c04d2b190f581f52 Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Fix handling of invalid urls in QDataStream << QUrlDavid Faure2012-05-231-1/+3
| | | | | | | | | | | When given an invalid url, the output shouldn't be a valid url. KDE's kurltest detected this regression compared to Qt4, where all invalid urls were empty in toString() -- but we don't want that, to give as much feedback as possible to the user. Change-Id: Ie53e6e1c0a1d4bb9e12b820220dfb7e2f7753959 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add the QUrl::FullyDecoded flag to the component formattingThiago Macieira2012-05-221-42/+144
| | | | | | | | | | | | | | | | | | This allows the QUrl component getters to return fully decoded data, like they did in Qt 4. This is necessary for some use-cases where the component like the user name, password or path are used outside the context of a URL. In those contexts, the percent-encoded data makes no sense, and the loss of data of what could be represented in a URL is acceptable. Also take the opportunity to expand the documentation of those getter methods, explaining what the options argument does. Discussed-on: http://lists.qt-project.org/pipermail/development/2012-May/003811.html Change-Id: I89f743cde78c02f169c88314bff0768714341419 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: David Faure <faure@kde.org> Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
* Add QUrl::ParsingMode to the component setters in QUrlThiago Macieira2012-05-221-27/+178
| | | | | | | | | | | | | | This allows one to instruct QUrl to ignore the percent-encodings and interpret the data exactly as provided. This is useful in certain use-cases where the data comes from a non-URL context. The strict-mode checking of the components is not implemented yet. Currently, the behaviour is equal to that of TolerantMode. Discussed-on: http://lists.qt-project.org/pipermail/development/2012-May/003811.html Change-Id: Ia5abe045a8ce7f9b50cbce3b5a7e3735e068d03a Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
* Add the QUrl::DecodedMode parsing modeThiago Macieira2012-05-221-5/+18
| | | | | | | | | | | This mode will be used to support parsing of URL components in their fully-decoded forms. It is not permitted when parsing the full URL, as that would be ambiguous. Change-Id: Id8d39a740845ae8d1efef894085280b322e39c0a Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: David Faure <faure@kde.org> Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
* Port away from QUrl::MostDecodedThiago Macieira2012-05-221-2/+2
| | | | | | | | | | | Since we're about to introduce QUrl::FullyDecoded, this QUrl::MostDecoded value would be confusing. Replace its uses with what was intended at the point in question. Change-Id: Iefd87bc33d37bace507c5cb0f206fa902e08e2df Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: David Faure <faure@kde.org> Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
* Elaborate QUrl::toString() documentation.Leonard Lee2012-05-211-0/+2
| | | | | Change-Id: If2d726e7b4e8d408312fcb138c3dd146926bfd9a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrl: using sectionIsPresent in operator== broke for local files.David Faure2012-05-141-1/+5
| | | | | | | | | QUrl::fromLocalFile("/foo") doesn't set Host, but QUrl("file:///foo") does (to remember that it saw a Host section, even if empty, which is useful for urls like "remote://"). So ignore the Host flag in operator==. Change-Id: I4322b4a75420c4e42766c0d65c1b121f28028a76 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrl: a url with a fragment or query, and one without, are different.David Faure2012-05-141-1/+8
| | | | | | | | | Fix operator== and operator< so that a URL with an empty fragment or query, is not treated as equal to a URL without any fragment or query. This restores the Qt4 behavior on this particular issue. Change-Id: Ie989f37353fb13c791b1d558d638d2e8a5b5d1b8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix a crash when parsing a URL with username and port, but no passwordThiago Macieira2012-05-101-1/+1
| | | | | | | | | | This was crashing because the ':' was found past the end of the username, causing the recoder to run from position 22 to 11, via the long way around the memory. Change-Id: Ic1ae596f34f7db857fb4210294974fb5a6adf691 Reviewed-by: Alexis Menard <alexis.menard@openbossa.org> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* Fix QUrl::StripTrailingSlash for the case of no path at all.David Faure2012-05-091-1/+1
| | | | | Change-Id: I1fd0fe4b9b67996732c85c1792415e371e865595 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix QUrl::toString(StripTrailingSlash) to not turn file:/// into file:David Faure2012-05-041-1/+1
| | | | | | | | It should only strip one slash (as the name indicates), and not if the path is just "/". Change-Id: I133a81977241de77a49d1d1559143d30e0bd52f8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>