From 7c575887386a3fad2eb12434e337e0b2d54dde3b Mon Sep 17 00:00:00 2001 From: nowrep Date: Thu, 4 Apr 2013 20:32:34 +0200 Subject: [PATCH] Cancel upload when trying to upload non-readable files. --- CHANGELOG | 1 + src/lib/webview/webpage.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 8e850b927..5169a0d10 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ Version 1.5.0 * added support for Proxy Auto-Config (PAC) * added option to open another private window from private window * added delete action in edit context menu on page + * cancel upload when trying to upload non-readable files * GreaseMonkey: added support for GM_Settings * fixed: size of preferences dialog on low-res screens diff --git a/src/lib/webview/webpage.cpp b/src/lib/webview/webpage.cpp index 9db2d8aa2..6079c912c 100644 --- a/src/lib/webview/webpage.cpp +++ b/src/lib/webview/webpage.cpp @@ -990,6 +990,14 @@ QString WebPage::chooseFile(QWebFrame* originatingFrame, const QString &oldFile) if (!fileName.isEmpty()) { s_lastUploadLocation = fileName; + + // Check if we can read from file + QFile file(fileName); + if (!file.open(QFile::ReadOnly)) { + const QString &msg = tr("Cannot read data from %1. Upload was cancelled!").arg(fileName); + QMessageBox::critical(view(), tr("Cannot read file!"), msg); + return QString(); + } } return fileName;