summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2012-04-03 13:58:39 -0300
committerQt by Nokia <qt-info@nokia.com>2012-04-10 22:54:37 +0200
commitd4f3052a1b210c09976883afbe0fac087171be4f (patch)
treee5e040b532d37de0aa214bdcf0a85047e413bf7a /src
parent81d1f79a7f4b0f67d71d1c8c5c74e5a56ab48097 (diff)
Adjust a double leading slash in the path for FTP to /%2F
Some FTP implementations (currently not including QNAM) strip the first slash off the path in an FTP URL so that the path in the URL is relative to the login path (the user's home directory). To reach the root directory, another slash is necessary, hence the double slash. In anticipation of future URL normalisation, which Qt 4 could do, "//" could be rendered to "/", so this extra slash should be "%2F". This operation is done only in QUrl::fromUserInput. Change-Id: If9619ef6b546a3f4026cb26b74a7a5a865123609 Reviewed-by: Shane Kearns <shane.kearns@accenture.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qurl.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 62ad732935..6a02dc165d 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -2561,6 +2561,16 @@ uint qHash(const QUrl &url, uint seed)
qHash(url.d->fragment);
}
+static QUrl adjustFtpPath(QUrl url)
+{
+ if (url.scheme() == ftpScheme()) {
+ QString path = url.path();
+ if (path.startsWith("//"))
+ url.setPath(QLatin1String("/%2F") + path.midRef(2));
+ }
+ return url;
+}
+
// The following code has the following copyright:
/*
@@ -2640,7 +2650,7 @@ QUrl QUrl::fromUserInput(const QString &userInput)
&& !url.scheme().isEmpty()
&& (!url.host().isEmpty() || !url.path().isEmpty())
&& urlPrepended.port() == -1)
- return url;
+ return adjustFtpPath(url);
// Else, try the prepended one and adjust the scheme from the host name
if (urlPrepended.isValid() && (!urlPrepended.host().isEmpty() || !urlPrepended.path().isEmpty()))
@@ -2649,7 +2659,7 @@ QUrl QUrl::fromUserInput(const QString &userInput)
const QString hostscheme = trimmedString.left(dotIndex).toLower();
if (hostscheme == ftpScheme())
urlPrepended.setScheme(ftpScheme());
- return urlPrepended;
+ return adjustFtpPath(urlPrepended);
}
return QUrl();