From 6c3a9666ed3d44dbd79a6495b2f4221e9aa3996f Mon Sep 17 00:00:00 2001 From: Geoff Hutchison Date: Tue, 10 Oct 2023 20:32:29 -0400 Subject: [PATCH] Add validation to the file format dialog Signed-off-by: Geoff Hutchison --- avogadro/qtgui/fileformatdialog.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/avogadro/qtgui/fileformatdialog.cpp b/avogadro/qtgui/fileformatdialog.cpp index ee2dc34442..16adfcee54 100644 --- a/avogadro/qtgui/fileformatdialog.cpp +++ b/avogadro/qtgui/fileformatdialog.cpp @@ -42,6 +42,14 @@ FileFormatDialog::FormatFilePair FileFormatDialog::fileToRead( if (fileName.isEmpty()) // user cancel return result; + if (FileFormat::validateFileName(fileName.toStdString()) == false) { + QMessageBox::warning( + parent, caption, + tr("The file name contains invalid characters. Please choose another " + "file name.")); + continue; + } + const Io::FileFormat* format = findFileFormat( parent, caption, fileName, FileFormat::File | FileFormat::Read);