diff --git a/src/activitypub/mocks.js b/src/activitypub/mocks.js index 660cb223f9..051b17f96e 100644 --- a/src/activitypub/mocks.js +++ b/src/activitypub/mocks.js @@ -576,9 +576,9 @@ Mocks.actors.category = async (cid) => { outbox: `${nconf.get('url')}/category/${cid}/outbox`, type: 'Group', - name, + name: utils.decodeHTMLEntities(name), preferredUsername, - summary, + summary: utils.decodeHTMLEntities(summary), // image, // todo once categories have cover photos icon, postingRestrictedToMods: !canPost, diff --git a/test/activitypub/actors.js b/test/activitypub/actors.js index 2e2375e2ce..e659713de3 100644 --- a/test/activitypub/actors.js +++ b/test/activitypub/actors.js @@ -16,7 +16,7 @@ const slugify = require('../../src/slugify'); const helpers = require('./helpers'); -describe('Actor asserton', () => { +describe('as:Person (Actor asserton)', () => { before(async () => { meta.config.activitypubEnabled = 1; await install.giveWorldPrivileges(); @@ -514,6 +514,26 @@ describe('Controllers', () => { url: `${nconf.get('url')}/assets/uploads/files/test.png`, }); }); + + it('should not contain html entities in name and summary', async () => {const payload = {}; + payload[cid] = { + name: 'One & Two', + description: 'This is a category for one & two', + }; + await categories.update(payload); + + const { body } = await request.get(`${nconf.get('url')}/category/${cid}`, { + headers: { + Accept: 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', + }, + }); + + const { name, summary } = body; + assert.deepStrictEqual({ name, summary }, { + name: 'One & Two', + summary: 'This is a category for one & two', + }); + }); }); describe('Instance Actor endpoint', () => {