Skip to content

Commit afa4af9

Browse files
committed
contacts: do not read members from wrong group or doc
1 parent 5d7883b commit afa4af9

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

contacts/src/rdflib/queries/GroupQuery.spec.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,5 +160,52 @@ describe(GroupQuery.name, () => {
160160
const result = query.queryMembers();
161161
expect(result).toEqual([]);
162162
});
163+
164+
it("does not return a member from wrong group", () => {
165+
const store = graph();
166+
const groupNode = sym(
167+
"http://pod.test/alice/contacts/1/group/1/index.ttl#this",
168+
);
169+
const wrongGroup = sym(
170+
"http://pod.test/alice/contacts/1/group/wrong/index.ttl#this",
171+
);
172+
store.add(
173+
wrongGroup,
174+
vcard("hasMember"),
175+
sym("http://pod.test/alice/contacts/Person/1#this"),
176+
groupNode.doc(),
177+
);
178+
store.add(
179+
sym("http://pod.test/alice/contacts/Person/1#this"),
180+
vcard("fn"),
181+
lit("Bob"),
182+
groupNode.doc(),
183+
);
184+
const query = new GroupQuery(store, groupNode);
185+
const result = query.queryMembers();
186+
expect(result).toEqual([]);
187+
});
188+
189+
it("does not return a member from wrong group document", () => {
190+
const store = graph();
191+
const groupNode = sym(
192+
"http://pod.test/alice/contacts/1/group/1/index.ttl#this",
193+
);
194+
store.add(
195+
groupNode,
196+
vcard("hasMember"),
197+
sym("http://pod.test/alice/contacts/Person/1#this"),
198+
sym("http://pod.test/wrong/contacts/Person/1#this"),
199+
);
200+
store.add(
201+
sym("http://pod.test/alice/contacts/Person/1#this"),
202+
vcard("fn"),
203+
lit("Bob"),
204+
groupNode.doc(),
205+
);
206+
const query = new GroupQuery(store, groupNode);
207+
const result = query.queryMembers();
208+
expect(result).toEqual([]);
209+
});
163210
});
164211
});

contacts/src/rdflib/queries/GroupQuery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class GroupQuery {
2323

2424
queryMembers() {
2525
return this.store
26-
.each(this.groupNode, vcard("hasMember"))
26+
.each(this.groupNode, vcard("hasMember"), null, this.groupDoc)
2727
.filter((it): it is NamedNode => isNamedNode(it))
2828
.map((node) => ({
2929
uri: node.value,

0 commit comments

Comments
 (0)