summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2020-11-16 17:28:22 +0000
committerEmmanuele Bassi <ebassi@gnome.org>2020-11-16 17:47:15 +0000
commitbb1463871c156b55585d63492f85a128956c04f5 (patch)
tree668fbe0cf2dc22438d23b888e6600c5f7db0e64c /gtk
parent9de2b4b0e1dbddb4fb891fb8e699c1c985ddeaf7 (diff)
downloadgtk+-bb1463871c156b55585d63492f85a128956c04f5.tar.gz
a11y: Ensure valid object paths in the fallback code
When falling back to using the program name to create a unique base path for the objects on the accessibility bus we need to ensure that the name is a valid DBus object path.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/a11y/gtkatspiroot.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/gtk/a11y/gtkatspiroot.c b/gtk/a11y/gtkatspiroot.c
index 9c23bd8e51..31afbe2316 100644
--- a/gtk/a11y/gtkatspiroot.c
+++ b/gtk/a11y/gtkatspiroot.c
@@ -659,6 +659,7 @@ gtk_at_spi_root_constructed (GObject *gobject)
{
const char *app_path = g_application_get_dbus_object_path (application);
+ /* No need to validate the path */
self->base_path = g_strconcat (app_path, "/a11y", NULL);
}
else
@@ -667,8 +668,27 @@ gtk_at_spi_root_constructed (GObject *gobject)
g_get_prgname (),
"/a11y",
NULL);
- }
+ /* Turn potentially invalid program names into something that can be
+ * used as a DBus path
+ */
+ size_t len = strlen (self->base_path);
+ for (size_t i = 0; i < len; i++)
+ {
+ char c = self->base_path[i];
+
+ if (c == '/')
+ continue;
+
+ if ((c >= '0' && c <= '9') ||
+ (c >= 'A' && c <= 'Z') ||
+ (c >= 'a' && c <= 'z') ||
+ (c == '_'))
+ continue;
+
+ self->base_path[i] = '_';
+ }
+ }
out:
G_OBJECT_CLASS (gtk_at_spi_root_parent_class)->constructed (gobject);