Skip to content

Commit 5117f7c

Browse files
committed
contacts: do not read contact names from other documents than group doc
1 parent afa4af9 commit 5117f7c

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,5 +207,32 @@ describe(GroupQuery.name, () => {
207207
const result = query.queryMembers();
208208
expect(result).toEqual([]);
209209
});
210+
211+
it("does not return a contact name from outside the group doc", () => {
212+
const store = graph();
213+
const groupNode = sym(
214+
"http://pod.test/alice/contacts/1/group/1/index.ttl#this",
215+
);
216+
store.add(
217+
groupNode,
218+
vcard("hasMember"),
219+
sym("http://pod.test/alice/contacts/Person/1#this"),
220+
groupNode.doc(),
221+
);
222+
store.add(
223+
sym("http://pod.test/alice/contacts/Person/1#this"),
224+
vcard("fn"),
225+
lit("Bob"),
226+
sym("http://other.test/document"),
227+
);
228+
const query = new GroupQuery(store, groupNode);
229+
const result = query.queryMembers();
230+
expect(result).toEqual([
231+
{
232+
uri: "http://pod.test/alice/contacts/Person/1#this",
233+
name: "",
234+
},
235+
]);
236+
});
210237
});
211238
});

contacts/src/rdflib/queries/GroupQuery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class GroupQuery {
2727
.filter((it): it is NamedNode => isNamedNode(it))
2828
.map((node) => ({
2929
uri: node.value,
30-
name: this.store.anyValue(node, vcard("fn")),
30+
name: this.store.anyValue(node, vcard("fn"), null, this.groupDoc) ?? "",
3131
}));
3232
}
3333
}

0 commit comments

Comments
 (0)