return droute_return_v_int32 (iter, atk_text_get_caret_offset (text));
}
+static gchar *
+validate_allocated_string (gchar *str)
+{
+ if (!str)
+ return g_strdup ("");
+ if (!g_utf8_validate (str, -1, NULL))
+ {
+ g_warning ("atk-bridge: received bad UTF-8 string from a get_text function");
+ g_free (str);
+ return g_strdup ("");
+ }
+ return str;
+}
+
static DBusMessage *
impl_GetText (DBusConnection * bus, DBusMessage * message, void *user_data)
{
return droute_invalid_arguments_error (message);
}
txt = atk_text_get_text (text, startOffset, endOffset);
- if (!txt)
- txt = g_strdup ("");
+ txt = validate_allocated_string (txt);
reply = dbus_message_new_method_return (message);
if (reply)
{
&intstart_offset, &intend_offset);
startOffset = intstart_offset;
endOffset = intend_offset;
- if (!txt)
- txt = g_strdup ("");
+ txt = validate_allocated_string (txt);
reply = dbus_message_new_method_return (message);
if (reply)
{
&intstart_offset, &intend_offset);
startOffset = intstart_offset;
endOffset = intend_offset;
- if (!txt)
- txt = g_strdup ("");
+ txt = validate_allocated_string (txt);
reply = dbus_message_new_method_return (message);
if (reply)
{
&intstart_offset, &intend_offset);
startOffset = intstart_offset;
endOffset = intend_offset;
- if (!txt)
- txt = g_strdup ("");
+ txt = validate_allocated_string (txt);
reply = dbus_message_new_method_return (message);
if (reply)
{
}
static const void *
-replace_null (const gint type,
+validate_for_dbus (const gint type,
const void *val)
{
switch (type)
case DBUS_TYPE_OBJECT_PATH:
if (!val)
return "";
+ else if (!g_utf8_validate (val, -1, NULL))
+ {
+ g_warning ("atk-bridge: Received bad UTF-8 string when emitting event");
+ return "";
+ }
else
return val;
default:
dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, type, &sub);
- val = replace_null ((int) *type, val);
+ val = validate_for_dbus ((int) *type, val);
dbus_message_iter_append_basic(&sub, (int) *type, &val);
dbus_message_iter_close_container(iter, &sub);
#include <stdlib.h>
#include <string.h>
+#include "glib.h"
#include "droute-variant.h"
if (!val)
val = "";
+ if (!g_utf8_validate (val, -1, NULL))
+ {
+ g_warning ("droute: Received bad UTF-8 string");
+ val = "";
+ }
+
if (!dbus_message_iter_open_container
(iter, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &sub))
{