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:
/*
&& !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()))
const QString hostscheme = trimmedString.left(dotIndex).toLower();
if (hostscheme == ftpScheme())
urlPrepended.setScheme(ftpScheme());
- return urlPrepended;
+ return adjustFtpPath(urlPrepended);
}
return QUrl();
// FYI: The scheme in the resulting url user
QUrl authUrl("user:pass@domain.com");
QTest::newRow("misc-1") << "user:pass@domain.com" << authUrl;
+
+ // FTP with double slashes in path
+ QTest::newRow("ftp-double-slash-1") << "ftp.example.com//path" << QUrl("ftp://ftp.example.com/%2Fpath");
+ QTest::newRow("ftp-double-slash-1") << "ftp://ftp.example.com//path" << QUrl("ftp://ftp.example.com/%2Fpath");
}
void tst_QUrl::fromUserInput()