aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vncviewer/UserDialog.cxx14
-rw-r--r--vncviewer/Viewport.cxx8
-rw-r--r--vncviewer/fltk_layout.h34
3 files changed, 50 insertions, 6 deletions
diff --git a/vncviewer/UserDialog.cxx b/vncviewer/UserDialog.cxx
index e94ab71f..0ac5009a 100644
--- a/vncviewer/UserDialog.cxx
+++ b/vncviewer/UserDialog.cxx
@@ -34,6 +34,7 @@
#include <rfb/Exception.h>
#include "i18n.h"
+#include "fltk_layout.h"
#include "parameters.h"
#include "UserDialog.h"
@@ -137,6 +138,11 @@ void UserDialog::getUserPasswd(char** user, char** password)
bool UserDialog::showMsgBox(int flags, const char* title, const char* text)
{
+ char buffer[1024];
+
+ if (fltk_escape(text, buffer, sizeof(buffer)) >= sizeof(buffer))
+ return 0;
+
// FLTK doesn't give us a flexible choice of the icon, so we ignore those
// bits for now.
@@ -146,16 +152,16 @@ bool UserDialog::showMsgBox(int flags, const char* title, const char* text)
switch (flags & 0xf) {
case M_OKCANCEL:
- return fl_choice(text, NULL, fl_ok, fl_cancel) == 1;
+ return fl_choice(buffer, NULL, fl_ok, fl_cancel) == 1;
case M_YESNO:
- return fl_choice(text, NULL, fl_yes, fl_no) == 1;
+ return fl_choice(buffer, NULL, fl_yes, fl_no) == 1;
case M_OK:
default:
if (((flags & 0xf0) == M_ICONERROR) ||
((flags & 0xf0) == M_ICONWARNING))
- fl_alert(text);
+ fl_alert(buffer);
else
- fl_message(text);
+ fl_message(buffer);
return true;
}
diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx
index 5b98d97b..5b5f5bba 100644
--- a/vncviewer/Viewport.cxx
+++ b/vncviewer/Viewport.cxx
@@ -42,6 +42,7 @@
#include "CConn.h"
#include "OptionsDialog.h"
#include "i18n.h"
+#include "fltk_layout.h"
#include "parameters.h"
#include "keysym2ucs.h"
@@ -575,6 +576,7 @@ void Viewport::initContextMenu()
void Viewport::popupContextMenu()
{
const Fl_Menu_Item *m;
+ char buffer[1024];
contextMenu->position(Fl::event_x(), Fl::event_y());
@@ -618,8 +620,10 @@ void Viewport::popupContextMenu()
OptionsDialog::showDialog();
break;
case ID_INFO:
- fl_message_title(_("VNC connection info"));
- fl_message(cc->connectionInfo());
+ if (fltk_escape(cc->connectionInfo(), buffer, sizeof(buffer)) < sizeof(buffer)) {
+ fl_message_title(_("VNC connection info"));
+ fl_message(buffer);
+ }
break;
case ID_ABOUT:
about_vncviewer();
diff --git a/vncviewer/fltk_layout.h b/vncviewer/fltk_layout.h
index 5119188c..61dea211 100644
--- a/vncviewer/fltk_layout.h
+++ b/vncviewer/fltk_layout.h
@@ -33,6 +33,40 @@ static inline int gui_str_len(const char *str)
return (int)(len + 0.5f);
}
+/* Escapes all @ in text as those have special meaning in labels */
+static inline int fltk_escape(const char *in, char *out, size_t maxlen)
+{
+ int len;
+
+ len = 0;
+
+ while (*in != '\0') {
+ if (*in == '@') {
+ if (maxlen >= 3) {
+ *out++ = '@';
+ *out++ = '@';
+ maxlen -= 2;
+ }
+
+ len += 2;
+ } else {
+ if (maxlen >= 2) {
+ *out++ = *in;
+ maxlen--;
+ }
+
+ len += 1;
+ }
+
+ in++;
+ }
+
+ if (maxlen)
+ *out = '\0';
+
+ return len;
+}
+
/**** MARGINS ****/
#define OUTER_MARGIN 10