Skip to content

Commit

Permalink
crossroads: Fixup introspection of children
Browse files Browse the repository at this point in the history
Fixes: #412
  • Loading branch information
diwic committed Jan 4, 2023
1 parent bf1e745 commit d913c60
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dbus-crossroads/src/crossroads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,11 @@ impl Crossroads {
let csub: &str = &c[substart..];
if csub.len() == 0 || csub.as_bytes()[0] != b'/' { continue; }
let csub1 = &csub[1..];
if direct_only && r.len() > 0 && csub1.as_bytes().starts_with(r[r.len()-1].as_bytes()) { continue; }
if direct_only && r.len() > 0 {
let prev = r[r.len()-1].as_bytes();
let b = csub1.as_bytes();
if b.len() > prev.len() && b.starts_with(prev) && b[prev.len()] == b'/' { continue; }
}
r.push(csub1);
};
r
Expand Down
4 changes: 4 additions & 0 deletions dbus-crossroads/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ const INTROSPECT: &str = r###"<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS O
</interface>
<node name="another_child_of_sample_object"/>
<node name="child_of_sample_object"/>
<node name="child_of_sample_object2"/>
<node name="very/deep/child"/>
</node>"###;

#[test]
Expand All @@ -164,9 +166,11 @@ fn introspect() {
});
cr.insert("/com/example/sample_object0", &[token], ());
cr.insert("/com/example/sample_object0/child_of_sample_object", &[], ());
cr.insert("/com/example/sample_object0/child_of_sample_object2", &[], ());
cr.insert("/com/example/sample_object0/child_of_sample_object/subchild", &[], ());
cr.insert("/com/example/sample_object0123", &[], ());
cr.insert("/com/example/sample_object0/another_child_of_sample_object", &[], ());
cr.insert("/com/example/sample_object0/very/deep/child", &[], ());

let msg = Message::new_method_call("com.example.dbusrs.crossroads.score", "/com/example/sample_object0",
"org.freedesktop.DBus.Introspectable", "Introspect").unwrap();
Expand Down

0 comments on commit d913c60

Please sign in to comment.