From 8e96e73ebce9e0e7bd9c9f55eb545c442fe93a70 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Thu, 14 Aug 2014 16:08:27 +0200 Subject: Doc: corrected autolink errors corelib io Task-number: QTBUG-40362 Change-Id: If11700d57db75ad7605bd8d53681002639c2e785 Reviewed-by: Jerome Pasion --- src/corelib/io/qurl.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'src/corelib/io/qurl.cpp') diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 7018b333f2..c109fc4d3a 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -2315,7 +2315,7 @@ void QUrl::setHost(const QString &host, ParsingMode mode) as DNS requests or in HTTP request headers). If that flag is not present, this function returns the International Domain Name (IDN) in Unicode form, according to the list of permissible top-level domains (see - idnWhiteList()). + idnWhitelist()). All other flags are ignored. Host names cannot contain control or percent characters, so the returned value can be considered fully decoded. @@ -2656,8 +2656,8 @@ void QUrl::setQuery(const QUrlQuery &query) Sets the query string of the URL to an encoded version of \a query. The contents of \a query are converted to a string internally, each pair delimited by the character returned by - pairDelimiter(), and the key and value are delimited by - valueDelimiter(). + queryPairDelimiter(), and the key and value are delimited by + queryValueDelimiter(). \note This method does not encode spaces (ASCII 0x20) as plus (+) signs, like HTML forms do. If you need that kind of encoding, you must encode @@ -2676,8 +2676,8 @@ void QUrl::setQuery(const QUrlQuery &query) Sets the query string of the URL to the encoded version of \a query. The contents of \a query are converted to a string internally, each pair delimited by the character returned by - pairDelimiter(), and the key and value are delimited by - valueDelimiter(). + queryPairDelimiter(), and the key and value are delimited by + queryValueDelimiter(). \obsolete Use QUrlQuery and setQuery(). @@ -2691,11 +2691,11 @@ void QUrl::setQuery(const QUrlQuery &query) Inserts the pair \a key = \a value into the query string of the URL. - The key/value pair is encoded before it is added to the query. The + The key-value pair is encoded before it is added to the query. The pair is converted into separate strings internally. The \a key and \a value is first encoded into UTF-8 and then delimited by the - character returned by valueDelimiter(). Each key/value pair is - delimited by the character returned by pairDelimiter(). + character returned by queryValueDelimiter(). Each key-value pair is + delimited by the character returned by queryPairDelimiter(). \note This method does not encode spaces (ASCII 0x20) as plus (+) signs, like HTML forms do. If you need that kind of encoding, you must encode @@ -2929,9 +2929,8 @@ QString QUrl::query(ComponentFormattingOptions options) const The fragment is sometimes also referred to as the URL "reference". Passing an argument of QString() (a null QString) will unset the fragment. - Passing an argument of QString("") (an empty but not null QString) - will set the fragment to an empty string (as if the original URL - had a lone "#"). + Passing an argument of QString("") (an empty but not null QString) will set the + fragment to an empty string (as if the original URL had a lone "#"). The \a fragment data is interpreted according to \a mode: in StrictMode, any '%' characters must be followed by exactly two hexadecimal characters @@ -3006,10 +3005,10 @@ QString QUrl::fragment(ComponentFormattingOptions options) const The fragment is sometimes also referred to as the URL "reference". - Passing an argument of QByteArray() (a null QByteArray) will unset - the fragment. Passing an argument of QByteArray("") (an empty but - not null QByteArray) will set the fragment to an empty string (as - if the original URL had a lone "#"). + Passing an argument of QByteArray() (a null QByteArray) will unset the fragment. + Passing an argument of QByteArray("") (an empty but not null QByteArray) + will set the fragment to an empty string (as if the original URL + had a lone "#"). \obsolete Use setFragment(), which has the same behavior of null / empty. -- cgit v1.2.3 From 974c2108352d1136835a615d3b56b827d6ef99dd Mon Sep 17 00:00:00 2001 From: Matti Paaso Date: Thu, 21 Aug 2014 16:51:22 +0300 Subject: Update license headers and add new license files - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund --- src/corelib/io/qurl.cpp | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) (limited to 'src/corelib/io/qurl.cpp') diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 5700b9ab24..252b21032e 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -1,41 +1,33 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Copyright (C) 2012 Intel Corporation. ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtCore module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information ** use the contact form at http://qt.digia.com/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** rights. These rights are described in the Digia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** ** $QT_END_LICENSE$ ** ****************************************************************************/ -- cgit v1.2.3 From 0c32af08a6d13b1db5bfedb248afc583c2fc22bc Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 2 Sep 2014 13:32:11 -0700 Subject: Fix handling of IPv6 addresses in QUrl::fromUserInput IPv6 addresses can start with ":", for which QDir::isAbsolute() would always return true (QResourceFileEngine::isRelativePath() returns constant false) and would trip the calculation for local files. Similarly, IPv6 addresses can start with strings that look like Windows drives: "a:", "b:", "c:", "d:", "e:" and "f:" (though not today, as those address blocks are unassigned). Since a valid IPv6 address will definitely require at least one more colon and Windows file names cannot contain ':', there's no ambiguity: a valid IPv6 address is never a valid file on Windows. This resolves the ambiguity in favor of IPv6 for Unix filenames (which can contain a colon) and in case of an URL containing scheme, relative path and no authority ("dead:beef::" for example could have been parsed as scheme() == "dead" and path() == "beef::"). Task-number: QTBUG-41089 Change-Id: Id9119af1acf8a75a786519af3b48b4ca3dbf3719 Reviewed-by: David Faure --- src/corelib/io/qurl.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/corelib/io/qurl.cpp') diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 252b21032e..d4c5e03058 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -4079,6 +4079,11 @@ static QUrl adjustFtpPath(QUrl url) return url; } +static bool isIp6(const QString &text) +{ + QIPAddressUtils::IPv6Address address; + return !text.isEmpty() && QIPAddressUtils::parseIp6(address, text.begin(), text.end()) == 0; +} // The following code has the following copyright: /* @@ -4135,8 +4140,18 @@ QUrl QUrl::fromUserInput(const QString &userInput, const QString &workingDirecto if (trimmedString.isEmpty()) return QUrl(); - // Check both QUrl::isRelative (to detect full URLs) and QDir::isAbsolutePath (since on Windows drive letters can be interpreted as schemes) + + // Check for IPv6 addresses, since a path starting with ":" is absolute (a resource) + // and IPv6 addresses can start with "c:" too + if (isIp6(trimmedString)) { + QUrl url; + url.setHost(trimmedString); + url.setScheme(QStringLiteral("http")); + return url; + } + QUrl url = QUrl(trimmedString, QUrl::TolerantMode); + // Check both QUrl::isRelative (to detect full URLs) and QDir::isAbsolutePath (since on Windows drive letters can be interpreted as schemes) if (url.isRelative() && !QDir::isAbsolutePath(trimmedString)) { QFileInfo fileInfo(QDir(workingDirectory), trimmedString); if ((options & AssumeLocalFile) || fileInfo.exists()) @@ -4181,6 +4196,15 @@ QUrl QUrl::fromUserInput(const QString &userInput) { QString trimmedString = userInput.trimmed(); + // Check for IPv6 addresses, since a path starting with ":" is absolute (a resource) + // and IPv6 addresses can start with "c:" too + if (isIp6(trimmedString)) { + QUrl url; + url.setHost(trimmedString); + url.setScheme(QStringLiteral("http")); + return url; + } + // Check first for files, since on Windows drive letters can be interpretted as schemes if (QDir::isAbsolutePath(trimmedString)) return QUrl::fromLocalFile(trimmedString); -- cgit v1.2.3