From d3b67c1e2249d4a1ee373904b918e88de17d1c26 Mon Sep 17 00:00:00 2001 From: Lawrence Lee <45837045+Lawrence37@users.noreply.github.com> Date: Sun, 15 Aug 2021 12:23:29 -0700 Subject: [PATCH] Fix empty dialog messages Escape ampersands and angle brackets in some Gtk::MessageDialogs. Closes #6306. --- rtgui/editorpanel.cc | 2 +- rtgui/filebrowser.cc | 4 ++-- rtgui/filecatalog.cc | 2 +- rtgui/filepanel.cc | 4 ++-- rtgui/guiutils.cc | 4 ++-- rtgui/rtwindow.cc | 8 ++++---- rtgui/saveasdlg.cc | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index d12489a13..78a07ddd6 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -1788,7 +1788,7 @@ bool EditorPanel::idle_saveImage (ProgressConnector *pc, delete ld; } } else { - Glib::ustring msg_ = Glib::ustring ("") + fname + ": Error during image processing\n"; + Glib::ustring msg_ = Glib::ustring ("") + escapeHtmlChars(fname) + ": Error during image processing\n"; Gtk::MessageDialog msgd (*parent, msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msgd.run (); diff --git a/rtgui/filebrowser.cc b/rtgui/filebrowser.cc index b96a5ecd1..97e724174 100644 --- a/rtgui/filebrowser.cc +++ b/rtgui/filebrowser.cc @@ -879,7 +879,7 @@ void FileBrowser::menuItemActivated (Gtk::MenuItem* m) } else { // Target directory creation failed, we clear the darkFramesPath setting options.rtSettings.darkFramesPath.clear(); - Glib::ustring msg_ = Glib::ustring::compose (M("MAIN_MSG_PATHDOESNTEXIST"), options.rtSettings.darkFramesPath) + Glib::ustring msg_ = Glib::ustring::compose (M("MAIN_MSG_PATHDOESNTEXIST"), escapeHtmlChars(options.rtSettings.darkFramesPath)) + "\n\n" + M("MAIN_MSG_OPERATIONCANCELLED"); Gtk::MessageDialog msgd (msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msgd.set_title(M("TP_DARKFRAME_LABEL")); @@ -955,7 +955,7 @@ void FileBrowser::menuItemActivated (Gtk::MenuItem* m) } else { // Target directory creation failed, we clear the flatFieldsPath setting options.rtSettings.flatFieldsPath.clear(); - Glib::ustring msg_ = Glib::ustring::compose (M("MAIN_MSG_PATHDOESNTEXIST"), options.rtSettings.flatFieldsPath) + Glib::ustring msg_ = Glib::ustring::compose (M("MAIN_MSG_PATHDOESNTEXIST"), escapeHtmlChars(options.rtSettings.flatFieldsPath)) + "\n\n" + M("MAIN_MSG_OPERATIONCANCELLED"); Gtk::MessageDialog msgd (msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msgd.set_title(M("TP_FLATFIELD_LABEL")); diff --git a/rtgui/filecatalog.cc b/rtgui/filecatalog.cc index 58c1bbc1b..d6c440570 100644 --- a/rtgui/filecatalog.cc +++ b/rtgui/filecatalog.cc @@ -1283,7 +1283,7 @@ void FileCatalog::renameRequested(const std::vector& tbe) /* check if filename already exists*/ if (Glib::file_test (nfname, Glib::FILE_TEST_EXISTS)) { - Glib::ustring msg_ = Glib::ustring("") + nfname + ": " + M("MAIN_MSG_ALREADYEXISTS") + ""; + Glib::ustring msg_ = Glib::ustring("") + escapeHtmlChars(nfname) + ": " + M("MAIN_MSG_ALREADYEXISTS") + ""; Gtk::MessageDialog msgd (msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msgd.run (); } else { diff --git a/rtgui/filepanel.cc b/rtgui/filepanel.cc index 974482f41..682dd1746 100644 --- a/rtgui/filepanel.cc +++ b/rtgui/filepanel.cc @@ -313,7 +313,7 @@ bool FilePanel::imageLoaded( Thumbnail* thm, ProgressConnector") + M("MAIN_MSG_CANNOTLOAD") + " \"" + thm->getFileName() + "\" .\n" + M("MAIN_MSG_TOOMANYOPENEDITORS") + ""; + Glib::ustring msg_ = Glib::ustring("") + M("MAIN_MSG_CANNOTLOAD") + " \"" + escapeHtmlChars(thm->getFileName()) + "\" .\n" + M("MAIN_MSG_TOOMANYOPENEDITORS") + ""; Gtk::MessageDialog msgd (*parent, msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msgd.run (); goto MAXGDIHANDLESREACHED; @@ -334,7 +334,7 @@ bool FilePanel::imageLoaded( Thumbnail* thm, ProgressConnectorset_title_decorated(pl->thm->getFileName()); } } else { - Glib::ustring msg_ = Glib::ustring("") + M("MAIN_MSG_CANNOTLOAD") + " \"" + thm->getFileName() + "\" .\n"; + Glib::ustring msg_ = Glib::ustring("") + M("MAIN_MSG_CANNOTLOAD") + " \"" + escapeHtmlChars(thm->getFileName()) + "\" .\n"; Gtk::MessageDialog msgd (*parent, msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msgd.run (); } diff --git a/rtgui/guiutils.cc b/rtgui/guiutils.cc index 98ab9606a..f3100c291 100644 --- a/rtgui/guiutils.cc +++ b/rtgui/guiutils.cc @@ -221,7 +221,7 @@ bool confirmOverwrite (Gtk::Window& parent, const std::string& filename) bool safe = true; if (Glib::file_test (filename, Glib::FILE_TEST_EXISTS)) { - Glib::ustring msg_ = Glib::ustring ("\"") + Glib::path_get_basename (filename) + "\": " + Glib::ustring msg_ = Glib::ustring ("\"") + escapeHtmlChars(Glib::path_get_basename (filename)) + "\": " + M("MAIN_MSG_ALREADYEXISTS") + "\n" + M("MAIN_MSG_QOVERWRITE"); Gtk::MessageDialog msgd (parent, msg_, true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_YES_NO, true); safe = (msgd.run () == Gtk::RESPONSE_YES); @@ -232,7 +232,7 @@ bool confirmOverwrite (Gtk::Window& parent, const std::string& filename) void writeFailed (Gtk::Window& parent, const std::string& filename) { - Glib::ustring msg_ = Glib::ustring::compose(M("MAIN_MSG_WRITEFAILED"), filename); + Glib::ustring msg_ = Glib::ustring::compose(M("MAIN_MSG_WRITEFAILED"), escapeHtmlChars(filename)); Gtk::MessageDialog msgd (parent, msg_, true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msgd.run (); } diff --git a/rtgui/rtwindow.cc b/rtgui/rtwindow.cc index baa44cabe..1b90d631b 100755 --- a/rtgui/rtwindow.cc +++ b/rtgui/rtwindow.cc @@ -501,22 +501,22 @@ void RTWindow::showErrors() // alerting users if the default raw and image profiles are missing if (options.is_defProfRawMissing()) { options.defProfRaw = DEFPROFILE_RAW; - Gtk::MessageDialog msgd (*this, Glib::ustring::compose (M ("OPTIONS_DEFRAW_MISSING"), options.defProfRaw), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); + Gtk::MessageDialog msgd (*this, Glib::ustring::compose (M ("OPTIONS_DEFRAW_MISSING"), escapeHtmlChars(options.defProfRaw)), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msgd.run (); } if (options.is_bundledDefProfRawMissing()) { - Gtk::MessageDialog msgd (*this, Glib::ustring::compose (M ("OPTIONS_BUNDLED_MISSING"), options.defProfRaw), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); + Gtk::MessageDialog msgd (*this, Glib::ustring::compose (M ("OPTIONS_BUNDLED_MISSING"), escapeHtmlChars(options.defProfRaw)), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msgd.run (); options.defProfRaw = DEFPROFILE_INTERNAL; } if (options.is_defProfImgMissing()) { options.defProfImg = DEFPROFILE_IMG; - Gtk::MessageDialog msgd (*this, Glib::ustring::compose (M ("OPTIONS_DEFIMG_MISSING"), options.defProfImg), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); + Gtk::MessageDialog msgd (*this, Glib::ustring::compose (M ("OPTIONS_DEFIMG_MISSING"), escapeHtmlChars(options.defProfImg)), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msgd.run (); } if (options.is_bundledDefProfImgMissing()) { - Gtk::MessageDialog msgd (*this, Glib::ustring::compose (M ("OPTIONS_BUNDLED_MISSING"), options.defProfImg), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); + Gtk::MessageDialog msgd (*this, Glib::ustring::compose (M ("OPTIONS_BUNDLED_MISSING"), escapeHtmlChars(options.defProfImg)), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); msgd.run (); options.defProfImg = DEFPROFILE_INTERNAL; } diff --git a/rtgui/saveasdlg.cc b/rtgui/saveasdlg.cc index a4062d502..9fdb90f18 100644 --- a/rtgui/saveasdlg.cc +++ b/rtgui/saveasdlg.cc @@ -281,9 +281,9 @@ void SaveAsDialog::okPressed () + ": " + M("SAVEDLG_WARNFILENAME") + " \"" - + Glib::path_get_basename (fname) + + escapeHtmlChars(Glib::path_get_basename (fname)) + '.' - + formatOpts->getFormat().format + + escapeHtmlChars(formatOpts->getFormat().format) + "\"", true, Gtk::MESSAGE_WARNING,