Fixed another QUrl weirdness were urls with empty credentials contained an unnecessary @ before the hostname

FossilOrigin-Name: 9f7b11b9ab0c210395f8aade55e8de0a3d212ae6
This commit is contained in:
Kostas
2015-09-15 10:39:11 +00:00
parent a71355cbec
commit 45740da630
5 changed files with 30 additions and 28 deletions

View File

@@ -152,11 +152,7 @@ bool Fossil::pushWorkspace(const QUrl &url)
if(!url.isEmpty())
{
// QUrl generates bad local file url for Windows local paths with drive letters
if(url.isLocalFile())
params << url.toLocalFile();
else
params << url.toEncoded();
params << UrlToString(url);
params << "--once";
QStringList log_params = params;
@@ -182,12 +178,7 @@ bool Fossil::pullWorkspace(const QUrl &url)
if(!url.isEmpty())
{
// QUrl generates bad local file url for Windows local paths with drive letters
if(url.isLocalFile())
params << url.toLocalFile();
else
params << url.toEncoded();
params << UrlToString(url);
params << "--once";
QStringList log_params = params;
@@ -440,12 +431,7 @@ bool Fossil::setSetting(const QString& name, const QString& value, bool global)
//------------------------------------------------------------------------------
bool Fossil::setRemoteUrl(const QUrl& url)
{
QString u = url.toEncoded();
// QUrl generates bad local file url for Windows local paths with drive letters
if(url.isLocalFile())
u = url.toLocalFile();
QString u = UrlToString(url);
if(url.isEmpty())
u = "off";

View File

@@ -525,6 +525,21 @@ QString UrlToStringNoCredentials(const QUrl& url)
return url.toString(QUrl::PrettyDecoded|QUrl::RemoveUserInfo);
#endif
}
//------------------------------------------------------------------------------
// Attempt to address weird behaviour of QUrl to string conversions
QString UrlToString(const QUrl &url)
{
QString username = url.userName();
// QUrl generates bad local file url for Windows local paths with drive letters
if(url.isLocalFile())
return url.toLocalFile();
else if(username.isEmpty()) // QUrl generates an invalid url like http://@host.domain/path
return UrlToStringNoCredentials(url);
else
return url.toEncoded();
}
//------------------------------------------------------------------------------
void SplitCommandLine(const QString &commandLine, QString &command, QString &extraParams)
{

View File

@@ -63,6 +63,7 @@ bool KeychainDelete(QObject* parent, const QUrl& url, QSettings &settings);
QString HashString(const QString &str);
QString UrlToStringDisplay(const QUrl &url);
QString UrlToStringNoCredentials(const QUrl& url);
QString UrlToString(const QUrl &url);
void SplitCommandLine(const QString &commandLine, QString &command, QString &extraParams);
bool SpawnExternalProcess(QObject *processParent, const QString& command, const QStringList& fileList, const stringset_t& pathSet, const QString &workspaceDir, UICallback &uiCallback);
void TrimStringList(QStringList &list);