diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-02-19 21:12:15 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-02-19 21:12:15 +0900 |
commit | 6edd8a23765285350a667ae214f5e450f5f24129 (patch) | |
tree | 9c6d28adfd82821c3dea0aee5cf112adb5678f62 | |
parent | 23008cac0c351d2e30583c53456394bbd4d14c5a (diff) | |
download | libquotient-6edd8a23765285350a667ae214f5e450f5f24129.tar.gz libquotient-6edd8a23765285350a667ae214f5e450f5f24129.zip |
Room::downloadFile: construct the temporary filename more carefully
Closes #279.
-rw-r--r-- | lib/room.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/room.cpp b/lib/room.cpp index f6956d82..c6376a26 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -56,6 +56,7 @@ #include <QtCore/QPointer> #include <QtCore/QDir> #include <QtCore/QTemporaryFile> +#include <QtCore/QRegularExpression> #include <QtCore/QMimeDatabase> #include <array> @@ -1804,7 +1805,8 @@ void Room::downloadFile(const QString& eventId, const QUrl& localFilename) { // Build our own file path, starting with temp directory and eventId. filePath = eventId; - filePath = QDir::tempPath() % '/' % filePath.replace(':', '_') % + filePath = QDir::tempPath() % '/' % + filePath.replace(QRegularExpression("[/\\<>|\"*?:]"), "_") % '#' % d->fileNameToDownload(event); } auto job = connection()->downloadFile(fileUrl, filePath); |