aboutsummaryrefslogtreecommitdiff
path: root/lib/events
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-03-23 20:43:02 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-03-23 20:43:02 +0900
commit23352250c9b9f9fa7d1d46294f8c1a7de1e19f61 (patch)
tree21e5cf416346489f4ea2928785030c14a984a9f6 /lib/events
parent19b94c0643b6f1f1f4fa327e50b69fb11675cf21 (diff)
downloadlibquotient-23352250c9b9f9fa7d1d46294f8c1a7de1e19f61.tar.gz
libquotient-23352250c9b9f9fa7d1d46294f8c1a7de1e19f61.zip
Room::downloadFile(): Tighten URL validations
Check the URL before passing over to Connection::downloadFile(), not only the file name.
Diffstat (limited to 'lib/events')
-rw-r--r--lib/events/eventcontent.cpp6
-rw-r--r--lib/events/eventcontent.h2
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/events/eventcontent.cpp b/lib/events/eventcontent.cpp
index 9a5e872c..77f756cd 100644
--- a/lib/events/eventcontent.cpp
+++ b/lib/events/eventcontent.cpp
@@ -50,6 +50,12 @@ FileInfo::FileInfo(const QUrl& u, const QJsonObject& infoJson,
mimeType = QMimeDatabase().mimeTypeForData(QByteArray());
}
+bool FileInfo::isValid() const
+{
+ return url.scheme() == "mxc"
+ && (url.authority() + url.path()).count('/') == 1;
+}
+
void FileInfo::fillInfoJson(QJsonObject* infoJson) const
{
Q_ASSERT(infoJson);
diff --git a/lib/events/eventcontent.h b/lib/events/eventcontent.h
index 0588c0e2..ab31a75d 100644
--- a/lib/events/eventcontent.h
+++ b/lib/events/eventcontent.h
@@ -94,6 +94,8 @@ namespace QMatrixClient
FileInfo(const QUrl& u, const QJsonObject& infoJson,
const QString& originalFilename = {});
+ bool isValid() const;
+
void fillInfoJson(QJsonObject* infoJson) const;
/**