summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qurl.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QUrl: fromLocalFile(QString()) should lead to an empty URL.David Faure2014-07-261-0/+4
| | | | | | | | | | | | | | This is much more useful than the URL "file:", it allows to use "empty path" and "empty URL" for the same meaning (e.g. not set). QFileDialog actually uses "file:" though, as the URL for the "My Computer" item in the sidebar. This patch preserves that. [ChangeLog][QtCore][QUrl] QUrl::fromLocalFile now returns an empty URL if the input string is empty. Change-Id: Ib5ce1a3cdf5f229368e5bcd83c62c1d1ac9f8a17 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add QUrl::fromUserInput overload with a cwd argument.David Faure2014-05-061-0/+60
| | | | | | | | Useful for any application that can take URLs on the command-line, so that full paths and relative paths can also be accepted. Change-Id: I8a2c50f36d60bdc49c065b3065972fd5d45fa12a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make a URL with absent authority be different from one with an empty oneThiago Macieira2014-02-171-6/+14
| | | | | | | | | | | | This partially reverts 5764f5e6eaf149116a818658883cf4fae9830f30 and fixes the problem differently. After this commit, "file:///foo" is still equal to "file:/foo", but "foo:///foo" becomes different from "foo:/foo", as it should be. Task-number: QTBUG-36151 Change-Id: Ia38638b0f30a7dcf110aa89aa427254c007fc107 Reviewed-by: David Faure <david.faure@kdab.com>
* Make QUrl::isLocalFile fast by storing a flagThiago Macieira2014-02-101-9/+33
| | | | | | | | | | | | The XDG specification for file URIs requires us to use triple slashes in file:/// for URLs with absolute paths. I don't like special-casing any particular scheme, but we've done it for file for many years now. Since we need to test this situation in a couple of places, it's easier to just cache the result once, in setScheme (both functions). Change-Id: I078b45b5b6c861f4caee082b4730fd6f67684ae4 Reviewed-by: David Faure <david.faure@kdab.com>
* Fix typos in QUrl::toAce() documentation.Mitch Curtis2014-01-181-1/+1
| | | | | Change-Id: I6b101c57c537523fb48e57985e1d69c4327a67aa Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* Silence compiler warningMarcel Krems2013-11-041-1/+1
| | | | | | | | | | warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses] Change-Id: I15e283023918cd4ebc27e91812eadf95ba156d71 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: David Faure <david.faure@kdab.com>
* Clarify that the URL scheme does not include the ':'Kurt Pattyn2013-10-171-4/+13
| | | | | | | | | | From the documentation of setScheme it was not clear if the scheme should be terminated by a ':' or not. Documentation has been updated to clarify the expected syntax for the scheme. Change-Id: Ied8533beef7daa12e1d5e7da0649c184efb84522 Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Adding mark-up to boolean default values.Jerome Pasion2013-10-081-18/+18
| | | | | | | | | | | | | | | | | Default values should have mark-up to denote that they are code. This commit changes: -"property is true" to "property is \c true". -"Returns true" to "Returns \c true". -"property is false" to "property is \c false". -"returns true" to "returns \c true". -"returns false" to "returns \c false". src/3rdparty and non-documentation instances were ignored. Task-number: QTBUG-33360 Change-Id: Ie87eaa57af947caa1230602b61c5c46292a4cf4e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* Doc: Add docs for rvalue references and move constructorsGeir Vattekar2013-09-271-0/+17
| | | | | | | | | These members were introduced in 4.8, but left undocumented. Because we consider undocumented API to be internal, the members are \since 5.2. Change-Id: I52e2840a8cfaa7f59f410b3e2a06c0942ea06539 Reviewed-by: Jerome Pasion <jerome.pasion@digia.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* Add Mac type conversion functions to QtCoreMorten Johan Sørvig2013-09-211-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | New API: static QString QString::fromCFString(CFStringRef string); CFStringRef QString::toCFString() const; static QString QString::fromNSString(const NSString *string); NSString *QString::toNSString() const; static QUrl QUrl::fromCFURL(CFURLRef url); CFURLRef QUrl::toCFURL() const; static QUrl QUrl::fromNSURL(const NSURL *url); NSURL * QUrl::toNSURL() const; Add Q_OS_MAC-protected function declarations to header files, add implementation to _mm files. CF and NS types are forward-declared in the header files to avoid including the CoreFoundation and Foundation headers. This prevents accidental use of native types in application code. Add helper macros for forward- declaration to qglobal.h Add cf_returns_retained/ns_returns_autoreleased attributes to toCFString() and toNSURL(). These attributes assists the clang static analyzer. Add Q_DECL_ helper macros to qcompilerdetection.h. Add test functions (in _mac.mm files) to the QString and QUrl tests. Split out the test class declarations into a separate headers files. Change-Id: I60fd5e93f042316196284c3db0595835fe8c4ad4 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
* QUrl: ensure that setPath("//path") doesn't lead to scheme://pathDavid Faure2013-09-111-1/+3
| | | | | | | | | | | | | which would interpret 'path' as a hostname. The check is in the public setPath so that the internal one can still support parsing URLs such as ftp://ftp.example.com//path. [ChangeLog][Important Behavior Changes][QUrl and QUrlQuery]QUrl now normalizes the path given in setPath, removing ./ and ../ and duplicate slashes. Change-Id: I05ccd8a1d813de45e460384239c059418a8e6a08 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrl: Use decoded mode by default for individual getters/setters.David Faure2013-08-211-4/+4
| | | | | | | | | | | | | | | | | | | This fixes the wrong value for path() and fileName() when a path or file name actually contains a '%'. userInfo() and authority() are not individual getters, they combine two or more fields, so full decoding isn't possible (e.g. username containing a ':'). [ChangeLog][Important Behavior Changes][QUrl and QUrlQuery]QUrl now defaults to decoded mode in the getters and setters for userName, password, host, topLevelDomain, path and fileName. This means a '%' in one of those fields is now returned (or set) as '%' rather than "%25". In the unlikely case where the former behavior was expected, pass PrettyDecoded to the getter and TolerantMode to the setter. Change-Id: Iaeecbde9c269882e79f08b29ff8c661157c41743 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrl: fix host(FullyDecoded), it shouldn't trigger EncodeUnicode.David Faure2013-08-211-2/+5
| | | | | Change-Id: I9a62d5eb8b099b659cfcfc591c983b3d73ca9569 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrl: do not decode "#" in fragmentsThiago Macieira2013-08-041-3/+3
| | | | | | | | | | | | | | | | | For some time, we've assumed that the URL specification had a mistake in that it didn't allow the "#" character to appear decoded in the fragment. We've gotten away with it so far. However, turns out that the CoreFoundation NSURL class doesn't like it. So we have to be stricter. [ChangeLog][Important Behavior Changes][QUrl and QUrlQuery] QUrl no longer decodes %23 found in the fragment to "#" in the output of toString(QUrl::FullyEncoded) or toEncoded() Task-number: QTBUG-31945 Change-Id: If5e0fb37bae84710986c9ca89bd69ec98437cd63 Reviewed-by: David Faure (KDE) <faure@kde.org>
* Remove fully-decoded QUrl user info and authority sectionsThiago Macieira2013-08-041-28/+39
| | | | | | | | | | | | | | | | | | | | Those sections contain more than one components of a URL, separated by delimiters. For that reason, QUrl::FullyDecoded and QUrl::DecodedMode do not make sense, since they would cause the returned value to be ambiguous and/or fail to parse again. In fact, there was a comment in the test saying "look how it becomes ambiguous". Those modes are already forbidden in the setters and getters of the full URL (setUrl(), url(), toString() and toEncoded()). [ChangeLog][Important Behavior Changes][QUrl and QUrlQuery] QUrl no longer supports QUrl::FullyDecoded mode in authority() and userInfo(), nor QUrl::DecodedMode in setAuthority() and setUserInfo(). Change-Id: I538f7981a9f5a09f07d3879d31ccf6f0c8bfd940 Reviewed-by: David Faure (KDE) <faure@kde.org>
* QUrl: remove temporary codeThiago Macieira2013-08-041-3/+0
| | | | | | | | | The setting of EncodeDelimiters was temporary until we could remove the old qt_urlRecode "decode all" mode (not the FullyDecoded mode, that stays). Change-Id: Ic07ebe4bb7fc72351b65bfb4619b71206cc8c0cd Reviewed-by: David Faure (KDE) <faure@kde.org>
* Doc: update the QUrl and QUrlQuery documentationThiago Macieira2013-08-041-27/+87
| | | | | | | | Just minor fixes and changes in wording, to support the new understanding of the percent-encoded characters. Change-Id: I77ec10e41f32292d705e4aa8197b9ddce5bef6d2 Reviewed-by: David Faure (KDE) <faure@kde.org>
* QUrl: update our understanding of the encoding of delimitersThiago Macieira2013-08-041-192/+160
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The longer explanation can be found in the comment in qurl.cpp. The short version is as follows: Up to now, we considered that every character could be replaced with its percent-encoding equivalent and vice-versa, so long as the parsing of the URL did not change. For example, x:/path+path and x:/path%2Bpath were the same. However, to do this and yet be compliant with most URL uses in the real world, we had to add exceptions: - "/" and "%2F" were not the same in the path, despite the delimiter being behind (rationale was the complex definition of path) - "+" and "%2B" were not the same in the query, so we ended up not transforming any sub-delim in the query at all Now, we change our understanding based on the following line from RFC 3986 section 2.2: URIs that differ in the replacement of a reserved character with its corresponding percent-encoded octet are not equivalent. From now on, QUrl will not replace any sub-delim or gen-delim ("reserved character"), except where such a character could not exist in the first place. This simplifies the code and removes all exceptions. As a side-effect, this has also changed the behaviour of the "{" and "}" characters, which we previously allowed to remain decoded. [ChangeLog][Important Behavior Changes][QUrl and QUrlQuery] QUrl no longer considers all delimiter characters equivalent to their percent-encoded forms. Now, both classes always keep all delimiters exactly as they were in the original URL text. [ChangeLog][Important Behavior Changes][QUrl and QUrlQuery] QUrl no longer decodes %7B and %7D to "{" and "}" in the output of toString() Task-number: QTBUG-31660 Change-Id: Iba0b5b31b269635ac2d0adb2bb0dfb74c139e08c Reviewed-by: David Faure (KDE) <faure@kde.org>
* QUrl: add matches(url, options) method.David Faure2013-07-261-0/+69
| | | | | Change-Id: I534f494aecc48cc2accfcfcb692f35046250b493 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrl: let StripTrailingSlash remove multiple trailing slashesDavid Faure2013-07-201-2/+4
| | | | | Change-Id: Ic4c8f70bb729630d9110ed6766dd9e40f9ab4d80 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrl: add fileName() method. Complements QUrl::RemoveFilename.David Faure2013-07-201-0/+30
| | | | | Change-Id: Ieda43364214c3b7aee43040e176e29ad48c14271 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make QUrl store the first bad IPv6 character in the error stringThiago Macieira2013-07-201-11/+22
| | | | | Change-Id: I9a0a521ff5c3188ba6f862e2b91369cb61787359 Reviewed-by: David Faure (KDE) <faure@kde.org>
* Make QIPAddress::parseIp6 return the first bad characterThiago Macieira2013-07-201-1/+2
| | | | | | | In case of undetermined error, returns end. Change-Id: Ic5d16bab5fc56ad24f19da25f73f9b844ce11d3f Reviewed-by: David Faure (KDE) <faure@kde.org>
* QUrl: Make sure we don't return a dangling pointer from parseIpFutureThiago Macieira2013-07-201-2/+3
| | | | | Change-Id: I54bf8d0fe72b8db8d158899ee4525c8d067272b8 Reviewed-by: David Faure (KDE) <faure@kde.org>
* QUrl: Uppercase the version number in IPvFutureThiago Macieira2013-07-201-0/+4
| | | | | | | | | We don't know what it might be used for. The RFC for URI says it's an HEXDIG, and since we uppercase all other HEXDIGs already (in percent-encodings...). Change-Id: I56d0a81315576dd98eaa2657c0307d79332543a5 Reviewed-by: David Faure (KDE) <faure@kde.org>
* Fix IPvFuture use in QUrlThiago Macieira2013-07-201-5/+6
| | | | | | | | | We have no idea what it might contain, but test it anyway to make sure it works. Turns out there were a few bugs the unit tests have now caught. Change-Id: I0a6c868365feec31c2360b3c341c8ca6944f4352 Reviewed-by: David Faure (KDE) <faure@kde.org>
* Fix QUrl parsing of IPv6 hosts with encoded colonsThiago Macieira2013-07-201-5/+8
| | | | | | | | | | | | | Registered names and IP addresses can only contain unreserved characters (letters, digits, dots, hyphens, underscores) and the colon, which is a gen-delim. For registered names and IPv4 addresses, we can simply use the default config -- if anything that remains percent-encoded, it means it's not a valid hostname anyway. For IPv6, we just need to decode the colon. Change-Id: If8083d47f6e5375f760e7a6c59631c89e4da8378 Reviewed-by: David Faure (KDE) <faure@kde.org>
* QUrl: Add an "appendingTo" parameter to QUrl::appendFragmentThiago Macieira2013-07-201-4/+4
| | | | | | | | Will be needed in a future commit. Change-Id: Ia5f384442d25d277e7582a20d1c37da4303c64c3 Reviewed-by: David Faure (KDE) <faure@kde.org> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
* QUrl: remove old commented out code for normalized().David Faure2013-07-131-81/+0
| | | | | | | adjusted(NormalizePathSegments) does this. Change-Id: I4b17c39174b5c04edac8d51e5fef8cd052db4b3f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrl: add NormalizePathSegments to UrlFormattingOptionsDavid Faure2013-07-131-1/+7
| | | | | | | | | This is a bit like QDir::cleanPath(), but for URL paths. The code is shared with QDir::cleanPath(), by extracting the common parts it into a helper, qt_normalizePathSegments(). Change-Id: I7133c5e4aa2bf17fba98af13eb5371afba64197a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrl: add RemoveFilename to UrlFormattingOptions.David Faure2013-07-081-1/+10
| | | | | | | | This allows to find the parent directory url using url.adjusted(QUrl::RemoveFilename). Change-Id: I1ca433ac67e4f93080de54a9b7ab2e538509ed04 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QUrl: add "QUrl adjusted(options)" convenience method.David Faure2013-07-081-8/+55
| | | | | Change-Id: I5eea3e0dc7b56b88a56d813207b04661b8f05a55 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix QUrl::topLevelDomain(QUrl::FullyDecoded)David Faure2013-07-061-5/+5
| | | | | | | | | 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>
* 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: Fix compiler warning about uninitialized varKai Koehne2013-05-081-1/+1
| | | | | | | Fix gcc 4.8.0 warning about potential use of uninitialized variable. Change-Id: I0881b1209e9156323b2710c50256d4bed83930ca Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-02-141-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/concurrent/doc/qtconcurrent.qdocconf src/corelib/doc/qtcore.qdocconf src/corelib/global/qglobal.h src/dbus/doc/qtdbus.qdocconf src/dbus/qdbusmessage.h src/gui/doc/qtgui.qdocconf src/gui/image/qimagereader.cpp src/network/doc/qtnetwork.qdocconf src/opengl/doc/qtopengl.qdocconf src/opengl/qgl.h src/plugins/platforms/windows/qwindowswindow.cpp src/printsupport/doc/qtprintsupport.qdocconf src/sql/doc/qtsql.qdocconf src/testlib/doc/qttestlib.qdocconf src/tools/qdoc/doc/config/qt-cpp-ignore.qdocconf src/widgets/doc/qtwidgets.qdocconf src/xml/doc/qtxml.qdocconf Change-Id: Ie9a1fa2cc44bec22a0b942e817a1095ca3414629
| * Merge branch 'release' into stableSergio Ahumada2013-01-311-1/+1
| |\ | | | | | | | | | Change-Id: If3aa1b7ed75082eff6e9761ad82c83691135ed60
| | * Fix some more old references and links to NokiaSergio Ahumada2013-01-281-1/+1
| | | | | | | | | | | | | | | | | | | | | Task-number: QTBUG-28156 Change-Id: I9ba0d6f1e92103219bec1e61e716b6b2f269a8ad Reviewed-by: Laszlo Papp <lpapp@kde.org> Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* | | Remove unused variables and functions from the source codeThiago Macieira2013-02-021-5/+0
| | | | | | | | | | | | | | | | | | Change-Id: I5f37414ee4846b4fe774361f49367bc0d5874039 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* | | Comment out an unused global variable.Thiago Macieira2013-02-021-1/+1
| | | | | | | | | | | | | | | | | | | | | The variable is present only for completeness in qurl.cpp. Change-Id: I68d7ca4cd52c14fbf8154e510737f7428d8e9679 Reviewed-by: David Faure (KDE) <faure@kde.org>
* | | 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>