Solving issue 1650: "Image information not displayed when dir has & in name"
This commit is contained in:
@@ -705,8 +705,8 @@ void EditorPanel::info_toggled () {
|
||||
}
|
||||
|
||||
infoString3 = Glib::ustring::compose ("<span size=\"small\">%1</span><span>%2</span>",
|
||||
Glib::path_get_dirname(openThm->getFileName()) + G_DIR_SEPARATOR_S,
|
||||
Glib::path_get_basename(openThm->getFileName()));
|
||||
escapeHtmlChars(Glib::path_get_dirname(openThm->getFileName())) + G_DIR_SEPARATOR_S,
|
||||
escapeHtmlChars(Glib::path_get_basename(openThm->getFileName())) );
|
||||
|
||||
infoString = Glib::ustring::compose ("%1\n%2\n%3",infoString1, infoString2, infoString3);
|
||||
}
|
||||
|
@@ -28,6 +28,37 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
Glib::ustring escapeHtmlChars(const Glib::ustring &src) {
|
||||
|
||||
// Sources chars to be escaped
|
||||
static const Glib::ustring srcChar("&<>");
|
||||
|
||||
// Destination strings, in the same order than the source
|
||||
static std::vector<Glib::ustring> dstChar(3);
|
||||
dstChar.at(0) = "&";
|
||||
dstChar.at(1) = "<";
|
||||
dstChar.at(2) = ">";
|
||||
|
||||
// Copying the original string, that will be modified
|
||||
Glib::ustring dst(src);
|
||||
|
||||
// Iterating all chars of the copy of the source string
|
||||
for (size_t i=0; i<dst.length();) {
|
||||
|
||||
// Looking out if it's part of the characters to be escaped
|
||||
size_t pos = srcChar.find_first_of(dst.at(i), 0);
|
||||
|
||||
if (pos != Glib::ustring::npos) {
|
||||
// If yes, replacing the char in the destination string
|
||||
dst.replace(i, 1, dstChar.at(pos));
|
||||
// ... and going forward by the length of the new string
|
||||
i += dstChar.at(pos).length();
|
||||
}
|
||||
else ++i;
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
bool removeIfThere (Gtk::Container* cont, Gtk::Widget* w, bool increference) {
|
||||
|
||||
Glib::ListHandle<Gtk::Widget*> list = cont->get_children ();
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include <gtkmm.h>
|
||||
#include "../rtengine/rtengine.h"
|
||||
|
||||
Glib::ustring escapeHtmlChars(const Glib::ustring &src);
|
||||
bool removeIfThere (Gtk::Container* cont, Gtk::Widget* w, bool increference=true);
|
||||
void thumbInterp (const unsigned char* src, int sw, int sh, unsigned char* dst, int dw, int dh);
|
||||
Glib::ustring removeExtension (const Glib::ustring& filename);
|
||||
|
Reference in New Issue
Block a user