From b92f2224bfd3e03cc935651f9d0464e8e08e26e7 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 7 Apr 2011 13:13:56 +0100 Subject: Remove support for trailing "." on arg0namespace --- bus/signals.c | 63 ++++++++-------------------------------------- doc/dbus-specification.xml | 12 --------- 2 files changed, 11 insertions(+), 64 deletions(-) diff --git a/bus/signals.c b/bus/signals.c index d0e72bf6..d7bddca3 100644 --- a/bus/signals.c +++ b/bus/signals.c @@ -821,15 +821,10 @@ bus_match_rule_parse_arg_match (BusMatchRule *rule, is_namespace = TRUE; - if (value_len > 0 && - _dbus_string_get_byte (value, value_len - 1) == '.') - value_len--; - if (!_dbus_validate_bus_namespace (value, 0, value_len)) { dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID, - "arg0namespace='%s' is not a valid (optionally " - "period-terminated) prefix of a bus name", + "arg0namespace='%s' is not a valid prefix of a bus name", _dbus_string_get_const_data (value)); goto failed; } @@ -1854,14 +1849,7 @@ match_rule_matches (BusMatchRule *rule, * which is an invalid namespace, but at some point the * daemon can't cover up for broken services. */ - int expected_period_index; - - if (expected_arg[expected_length - 1] == '.') - expected_period_index = expected_length - 1; - else - expected_period_index = expected_length; - - if (actual_arg[expected_period_index] != '.') + if (actual_arg[expected_length] != '.') return FALSE; } /* otherwise we had an exact match. */ @@ -2210,19 +2198,6 @@ test_parsing (void *data) bus_match_rule_unref (rule); } - rule = check_parse (TRUE, "arg0namespace='foo.'"); - if (rule != NULL) - { - _dbus_assert (rule->flags == BUS_MATCH_ARGS); - _dbus_assert (rule->args != NULL); - _dbus_assert (rule->args_len == 1); - _dbus_assert (strcmp (rule->args[0], "foo.") == 0); - _dbus_assert ((rule->arg_lens[0] & BUS_MATCH_ARG_NAMESPACE) - == BUS_MATCH_ARG_NAMESPACE); - - bus_match_rule_unref (rule); - } - rule = check_parse (TRUE, "arg0namespace='foo.bar'"); if (rule != NULL) { @@ -2236,19 +2211,6 @@ test_parsing (void *data) bus_match_rule_unref (rule); } - rule = check_parse (TRUE, "arg0namespace='foo.bar.'"); - if (rule != NULL) - { - _dbus_assert (rule->flags == BUS_MATCH_ARGS); - _dbus_assert (rule->args != NULL); - _dbus_assert (rule->args_len == 1); - _dbus_assert (strcmp (rule->args[0], "foo.bar.") == 0); - _dbus_assert ((rule->arg_lens[0] & BUS_MATCH_ARG_NAMESPACE) - == BUS_MATCH_ARG_NAMESPACE); - - bus_match_rule_unref (rule); - } - /* Only arg0namespace is supported. */ rule = check_parse (FALSE, "arg1namespace='foo'"); _dbus_assert (rule == NULL); @@ -2259,7 +2221,14 @@ test_parsing (void *data) rule = check_parse (FALSE, "arg0namespace=''"); _dbus_assert (rule == NULL); - /* Two trailing periods on otherwise-valid namespaces aren't allowed. */ + /* Trailing periods aren't allowed (earlier versions of the arg0namespace + * spec allowed a single trailing period, which altered the semantics) */ + rule = check_parse (FALSE, "arg0namespace='foo.'"); + _dbus_assert (rule == NULL); + + rule = check_parse (FALSE, "arg0namespace='foo.bar.'"); + _dbus_assert (rule == NULL); + rule = check_parse (FALSE, "arg0namespace='foo..'"); _dbus_assert (rule == NULL); @@ -2454,13 +2423,9 @@ should_not_match_message_1[] = { static const char * should_match_message_2[] = { - /* EXAMPLE_NAME is in all of these namespaces, specified with and without a - * trailing period */ - "arg0namespace='com.example.backend.'", + /* EXAMPLE_NAME is in all of these namespaces */ "arg0namespace='com.example.backend'", - "arg0namespace='com.example.'", "arg0namespace='com.example'", - "arg0namespace='com.'", "arg0namespace='com'", /* If the client specifies the name exactly, with no trailing period, then @@ -2476,12 +2441,6 @@ should_not_match_message_2[] = { /* These are not even prefixes */ "arg0namespace='com.example.backend.foo.bar'", "arg0namespace='com.example.backend.foobar'", - "arg0namespace='com.example.backend.fo.'", - - /* This should match anything within the namespace com.example.backend.foo, - * not including com.example.backend.foo itself. - */ - "arg0namespace='com.example.backend.foo.'", /* These are prefixes, but they're not parent namespaces. */ "arg0namespace='com.example.backend.fo'", diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index bef98871..bb8ecd27 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -3823,10 +3823,6 @@ bus name, this can also be used for messages whose first argument is an interface name. - If the value has a trailing period, then only bus names or interface names - within that namespace are matched. If it has no trailing period, an exact - match is also allowed. - For example, the match rule member='NameOwnerChanged',arg0namespace='com.example.backend' matches name owner changes for bus names such as @@ -3834,14 +3830,6 @@ com.example.backend.foo.bar, and com.example.backend itself. - On the other hand, the match rule - member='NameOwnerChanged',arg0namespace='com.example.backend.' - (with a trailing period in the namespace) matches owner changes for - com.example.backend.foo and - com.example.backend.foo.bar, but not for - com.example.backend. - - See also . -- cgit v1.2.3