diff options
author | Dan Winship <danw@gnome.org> | 2014-08-05 09:16:31 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2014-08-07 15:43:42 -0400 |
commit | 7e791ce3fe250190db9a54ce95490e90bc6e26b3 (patch) | |
tree | 197903a509252cf0cafc06efa1a14177f8127f66 /libnm | |
parent | 50d45acecbed8e297dfe8b41983ac4ca9a26bd19 (diff) | |
download | NetworkManager-7e791ce3fe250190db9a54ce95490e90bc6e26b3.tar.gz |
libnm, libnm-glib: belatedly replace _nm_client_is_object_path()
_nm_client_is_object_path() had been copied from
g_variant_is_object_path() with a note that it should be replaced when
we depended on GLib > 2.24, but it got missed when we actually updated
the dependency. Fix it now. (Also fix a nearby typo.)
Diffstat (limited to 'libnm')
-rw-r--r-- | libnm/nm-client.c | 48 |
1 files changed, 2 insertions, 46 deletions
diff --git a/libnm/nm-client.c b/libnm/nm-client.c index 97558fea42..02ff80db2f 100644 --- a/libnm/nm-client.c +++ b/libnm/nm-client.c @@ -1670,50 +1670,6 @@ nm_client_new_finish (GAsyncResult *result, GError **error) } /* - * Validate D-Bus object path. - * The function is copied and adjusted version of - * g_variant_serialiser_is_object_path() from glib. - * FIXME: The function can be replaced by g_variant_is_object_path() - * when we start using GLib >= 2.24 - */ -static gboolean -_nm_client_is_object_path (const char *string) -{ - gsize i; - - if (!g_utf8_validate (string, -1, NULL)) - return FALSE; - - /* The path must begin with an ASCII '/' (integer 47) character */ - if (string[0] != '/') - return FALSE; - - for (i = 1; string[i]; i++) { - /* Each element must only contain the ASCII characters - * "[A-Z][a-z][0-9]_" - */ - if (g_ascii_isalnum (string[i]) || string[i] == '_') - ; - /* must consist of elements separated by slash characters. */ - else if (string[i] == '/') { - /* No element may be the empty string. */ - /* Multiple '/' characters cannot occur in sequence. */ - if (string[i - 1] == '/') - return FALSE; - } else - return FALSE; - } - - /* A trailing '/' character is not allowed unless the path is the - * root path (a single '/' character). - */ - if (i > 1 && string[i - 1] == '/') - return FALSE; - - return TRUE; -} - -/* * constructor() shouldn't be overriden in most cases, rather constructed() * method is preferred and more useful. * But, this serves as a workaround for bindings (use) calling the constructor() @@ -1749,8 +1705,8 @@ constructor (GType type, if (dbus_path == NULL) { g_value_set_static_string (construct_params[i].value, NM_DBUS_PATH); } else { - if (!_nm_client_is_object_path (dbus_path)) { - g_warning ("Passsed D-Bus object path '%s' is invalid; using default '%s' instead", + if (!g_variant_is_object_path (dbus_path)) { + g_warning ("Passed D-Bus object path '%s' is invalid; using default '%s' instead", dbus_path, NM_DBUS_PATH); g_value_set_static_string (construct_params[i].value, NM_DBUS_PATH); } |