Commit 8e3c3820 authored by Alexander Saoutkin's avatar Alexander Saoutkin Committed by Fabian Vogt

Blacklist certain protocols

parent 97324a28
......@@ -30,6 +30,14 @@
#include "kiofuseservice.h"
#include "kiofusevfs.h"
const QStringList KIOFuseService::m_blacklist {
QStringLiteral("gdrive"), // @see #1
QStringLiteral("mtp"), // @see #2
// http(s) is buggy and gives back invalid sizes (similar to gdrive).
QStringLiteral("https"),
QStringLiteral("http")
};
KIOFuseService::~KIOFuseService()
{
// Make sure the VFS is unmounted before the member destructors run.
......@@ -74,6 +82,16 @@ QString KIOFuseService::mountUrl(const QString& remoteUrl, const QDBusMessage& m
{
message.setDelayedReply(true);
QUrl url = QUrl::fromUserInput(remoteUrl);
if(m_blacklist.contains(url.scheme()))
{
url.setPassword({}); // Lets not give back passwords in plaintext...
auto errorReply = message.createErrorReply(
QStringLiteral("org.kde.KIOFuse.VFS.Error.SchemeNotSupported"),
QStringLiteral("KIOFuse does not suport mounting of URLs with a scheme of %1").arg(url.scheme())
);
QDBusConnection::sessionBus().send(errorReply);
return QString();
}
kiofusevfs.mountUrl(url, [=] (auto node, int error) {
if(error)
{
......
......@@ -56,5 +56,6 @@ private:
QString m_mountpoint;
/** tempdir created if user does not specify mountpoint */
std::optional<QTemporaryDir> m_tempDir;
/** A list of protocols that are blacklisted (for various reasons). */
static const QStringList m_blacklist;
};
......@@ -108,6 +108,12 @@ void FileOpsTest::testDBusErrorReply()
QDBusPendingReply<QString> reply = m_kiofuse_iface.mountUrl(QStringLiteral("invalid URL"));
reply.waitForFinished();
QVERIFY(reply.isError());
QCOMPARE(reply.error().name(), QStringLiteral("org.kde.KIOFuse.VFS.Error.CannotMount"));
reply = m_kiofuse_iface.mountUrl(QStringLiteral("http://www.kde.org"));
reply.waitForFinished();
QVERIFY(reply.isError());
QCOMPARE(reply.error().name(), QStringLiteral("org.kde.KIOFuse.VFS.Error.SchemeNotSupported"));
}
void FileOpsTest::testLocalFileOps()
......
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