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/webenginewidgets | |
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/webenginewidgets')
-rw-r--r-- | src/webenginewidgets/api/qwebenginedownloaditem.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp index 4575f2929..05c6956ea 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp +++ b/src/webenginewidgets/api/qwebenginedownloaditem.cpp @@ -43,6 +43,7 @@ #include "profile_adapter.h" #include "qwebengineprofile_p.h" +#include "QFileInfo" QT_BEGIN_NAMESPACE @@ -534,6 +535,16 @@ void QWebEngineDownloadItem::setPath(QString path) return; } + 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; } |