From 9511c8273a2018e9d48b9f0d84a67f7eba7575d1 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 9 Oct 2020 22:33:51 +0100 Subject: [PATCH] a11y: Validate the DBus context path UUIDs use dashes to separate the various blocks; unfortunately, this results in an invalid DBus object path. Replace the dashes with an underscore. --- gtk/a11y/gtkatspicontext.c | 24 ++++++++++++++++++++++-- gtk/a11y/gtkatspicontextprivate.h | 3 +++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/gtk/a11y/gtkatspicontext.c b/gtk/a11y/gtkatspicontext.c index 31ef9a8842..4e0d205193 100644 --- a/gtk/a11y/gtkatspicontext.c +++ b/gtk/a11y/gtkatspicontext.c @@ -150,13 +150,13 @@ gtk_at_spi_context_constructed (GObject *gobject) if (self->root == NULL) { self->root = gtk_at_spi_root_new (self->bus_address); - self->connection = gtk_at_spi_root_get_connection (self->root); - g_object_set_data_full (G_OBJECT (display), "-gtk-atspi-root", self->root, g_object_unref); } + self->connection = gtk_at_spi_root_get_connection (self->root); + /* We use the application's object path to build the path of each * accessible object exposed on the accessibility bus; the path is * also used to access the object cache @@ -183,11 +183,23 @@ gtk_at_spi_context_constructed (GObject *gobject) self->context_path = g_strconcat (base_path, "/", uuid, NULL); + /* UUIDs use '-' as the separator, but that's not a valid character + * for a DBus object path + */ + size_t path_len = strlen (self->context_path); + for (size_t i = 0; i < path_len; i++) + { + if (self->context_path[i] == '-') + self->context_path[i] = '_'; + } + GTK_NOTE (A11Y, g_message ("ATSPI context path: %s", self->context_path)); g_free (base_path); g_free (uuid); + gtk_at_spi_context_register_object (self); + G_OBJECT_CLASS (gtk_at_spi_context_parent_class)->constructed (gobject); } @@ -391,3 +403,11 @@ gtk_at_spi_create_context (GtkAccessibleRole accessible_role, return NULL; } + +const char * +gtk_at_spi_context_get_context_path (GtkAtSpiContext *self) +{ + g_return_val_if_fail (GTK_IS_AT_SPI_CONTEXT (self), NULL); + + return self->context_path; +} diff --git a/gtk/a11y/gtkatspicontextprivate.h b/gtk/a11y/gtkatspicontextprivate.h index d7457af0ba..7c02efed7a 100644 --- a/gtk/a11y/gtkatspicontextprivate.h +++ b/gtk/a11y/gtkatspicontextprivate.h @@ -33,4 +33,7 @@ gtk_at_spi_create_context (GtkAccessibleRole accessible_role, GtkAccessible *accessible, GdkDisplay *display); +const char * +gtk_at_spi_context_get_context_path (GtkAtSpiContext *self); + G_END_DECLS