diff options
author | Tamas Zakor <ztamas@inf.u-szeged.hu> | 2019-05-03 15:53:25 +0200 |
---|---|---|
committer | Tamas Zakor <ztamas@inf.u-szeged.hu> | 2019-05-20 14:57:25 +0200 |
commit | e02bcb0855ebee0612cab0f3cd3f9fd494497336 (patch) | |
tree | ae5b9788f39f2d6b640772d25b8b446861de9afb /src/webengine/api | |
parent | d9643a016abc743db1dd879e7622cd27f88ff392 (diff) |
Add path validation for QWebEngineDownloadItem::setPath()
Do not set path if it ends with separator or if
it matches with an already existing directory name.
Task-number: QTBUG-75566
Change-Id: I4b78b28afe034c7589633c569a4945a36b32008e
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/webengine/api')
-rw-r--r-- | src/webengine/api/qquickwebenginedownloaditem.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp index cdb95fa53..7d51ed21d 100644 --- a/src/webengine/api/qquickwebenginedownloaditem.cpp +++ b/src/webengine/api/qquickwebenginedownloaditem.cpp @@ -43,6 +43,8 @@ #include "profile_adapter.h" #include "qquickwebengineprofile_p.h" +#include "QFileInfo" + using QtWebEngineCore::ProfileAdapterClient; QT_BEGIN_NAMESPACE @@ -427,6 +429,16 @@ void QQuickWebEngineDownloadItem::setPath(QString path) return; } if (d->downloadPath != path) { + if (QFileInfo(path).fileName().isEmpty()) { + qWarning("The download path does not include file name."); + return; + } + + if (QFileInfo(path).isDir()) { + qWarning("The download path matches with an already existing directory path."); + return; + } + d->downloadPath = path; Q_EMIT pathChanged(); } |