Commit 859ed4f1 authored by David Edmundson's avatar David Edmundson

Fix smb:/ handling

Summary:
smb:// is a URL with no host and no path
smb:/// is a URL with no host, but a valid path

The current code special cases smb:/ which isn't a real thing.

This results in smb:// falling through checkURL() and being incorrectly
modified into smb:/// creating a URL with a host, something different.

This code makes any smb:/ get converted into smb:// at the right place.
Then the special case for having no host or path are handled properly.

Test Plan: https://paste.kde.org/pfpwrlxva

Reviewers: apol, madcatx, elvisangelaccio, ngraham

Reviewed By: elvisangelaccio, ngraham

Subscribers: ngraham

Differential Revision: https://phabricator.kde.org/D8141
parent 1e662147
......@@ -175,18 +175,22 @@ QUrl SMBSlave::checkURL(const QUrl& kurl) const
{
qCDebug(KIO_SMB) << "checkURL " << kurl;
QString surl = kurl.url();
//transform any links in the form smb:/ into smb://
if (surl.startsWith(QLatin1String("smb:/"))) {
if (surl.length() == 5) // just the above
return kurl; // unchanged
if (surl.length() == 5) {
return QUrl("smb://");
}
if (surl.at(5) != '/') {
surl = "smb://" + surl.mid(5);
qCDebug(KIO_SMB) << "checkURL return1 " << surl << " " << QUrl(surl);
return QUrl(surl);
}
}
if (surl == QLatin1String("smb://")) {
return kurl; //unchanged
}
// smb:/ normaly have no userinfo
// smb:// normally have no userinfo
// we must redirect ourself to remove the username and password
if (surl.contains('@') && !surl.contains("smb://")) {
QUrl url(kurl);
......@@ -202,7 +206,7 @@ QUrl SMBSlave::checkURL(const QUrl& kurl) const
return url;
}
// no emtpy path
//if there's a valid host, don't have an empty path
QUrl url(kurl);
if (url.path().isEmpty())
......@@ -396,7 +400,7 @@ void SMBSlave::listDir( const QUrl& kurl )
udsentry.insert(KIO::UDSEntry::UDS_ACCESS, (S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH));
// QString workgroup = m_current_url.host().toUpper();
QUrl u("smb:/");
QUrl u("smb://");
u.setHost(dirpName);
// when libsmbclient knows
......@@ -423,7 +427,7 @@ void SMBSlave::listDir( const QUrl& kurl )
udsentry.insert(KIO::UDSEntry::UDS_MIME_TYPE, QString::fromLatin1("application/x-smb-workgroup"));
// QString workgroup = m_current_url.host().toUpper();
QUrl u("smb:/");
QUrl u("smb://");
u.setHost(dirpName);
udsentry.insert(KIO::UDSEntry::UDS_URL, u.url());
......
......@@ -121,7 +121,7 @@ SMBUrlType SMBUrl::getType() const
return m_type;
}
if (path(QUrl::FullyDecoded) == "/")
if (path().isEmpty() || path(QUrl::FullyDecoded) == "/")
{
if (host().isEmpty())
m_type = SMBURLTYPE_ENTIRE_NETWORK;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment