diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-03-23 20:43:02 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-03-23 21:49:22 +0900 |
commit | 9ba481f2c8e7f1db6144ece7119d8cc314c57bc5 (patch) | |
tree | 960d6605a770019b6bc4d918ef965141d91dac69 /lib/room.cpp | |
parent | 01d9f7b3f1785034503497798fb732ee6ee5fba3 (diff) | |
download | libquotient-9ba481f2c8e7f1db6144ece7119d8cc314c57bc5.tar.gz libquotient-9ba481f2c8e7f1db6144ece7119d8cc314c57bc5.zip |
Room::downloadFile(): Tighten URL validations
Check the URL before passing over to Connection::downloadFile(), not only the file name.
Diffstat (limited to 'lib/room.cpp')
-rw-r--r-- | lib/room.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/room.cpp b/lib/room.cpp index 7494917d..ce7bae04 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -1785,7 +1785,14 @@ void Room::downloadFile(const QString& eventId, const QUrl& localFilename) Q_ASSERT(false); return; } - const auto fileUrl = event->content()->fileInfo()->url; + const auto* const fileInfo = event->content()->fileInfo(); + if (!fileInfo->isValid()) + { + qCWarning(MAIN) << "Event" << eventId + << "has an empty or malformed mxc URL; won't download"; + return; + } + const auto fileUrl = fileInfo->url; auto filePath = localFilename.toLocalFile(); if (filePath.isEmpty()) { |