Commit 7d2ea878 authored by David Jarvie's avatar David Jarvie
Browse files

Check for invalid filename or non-existent local file

parent fe6f7fb5
...@@ -1626,14 +1626,17 @@ FileType fileType(const QMimeType& mimetype) ...@@ -1626,14 +1626,17 @@ FileType fileType(const QMimeType& mimetype)
FileErr checkFileExists(QString& filename, QUrl& url) FileErr checkFileExists(QString& filename, QUrl& url)
{ {
// Convert any relative file path to absolute // Convert any relative file path to absolute
// (using home directory as the default) // (using home directory as the default).
// This also supports absolute paths and absolute urls // This also supports absolute paths and absolute urls.
url = QUrl::fromUserInput(filename, QDir::homePath());
FileErr err = FileErr_None; FileErr err = FileErr_None;
url = QUrl::fromUserInput(filename, QDir::homePath());
if (filename.isEmpty()) if (filename.isEmpty())
{ {
url = QUrl();
err = FileErr_Blank; // blank file name err = FileErr_Blank; // blank file name
} }
else if (!url.isValid())
err = FileErr_Nonexistent;
else if (!url.isLocalFile()) else if (!url.isLocalFile())
{ {
filename = url.toDisplayString(); filename = url.toDisplayString();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment