diff --git a/public/src/modules/helpers.common.js b/public/src/modules/helpers.common.js index 820b0c09b3..b426fdaf51 100644 --- a/public/src/modules/helpers.common.js +++ b/public/src/modules/helpers.common.js @@ -27,6 +27,7 @@ module.exports = function (utils, Benchpress, relative_path) { increment, generateRepliedTo, generateWrote, + encodeURIComponent: _encodeURIComponent, isoTimeToLocaleString, shouldHideReplyContainer, humanReadableNumber, @@ -340,13 +341,17 @@ module.exports = function (utils, Benchpress, relative_path) { post.parent.displayname : '[[global:guest]]'; const isBeforeCutoff = post.timestamp < (Date.now() - (timeagoCutoff * oneDayInMs)); const langSuffix = isBeforeCutoff ? 'on' : 'ago'; - return `[[topic:replied-to-user-${langSuffix}, ${post.toPid}, ${relative_path}/post/${post.toPid}, ${displayname}, ${relative_path}/post/${post.pid}, ${post.timestampISO}]]`; + return `[[topic:replied-to-user-${langSuffix}, ${post.toPid}, ${relative_path}/post/${encodeURIComponent(post.toPid)}, ${displayname}, ${relative_path}/post/${encodeURIComponent(post.pid)}, ${post.timestampISO}]]`; } function generateWrote(post, timeagoCutoff) { const isBeforeCutoff = post.timestamp < (Date.now() - (timeagoCutoff * oneDayInMs)); const langSuffix = isBeforeCutoff ? 'on' : 'ago'; - return `[[topic:wrote-${langSuffix}, ${relative_path}/post/${post.pid}, ${post.timestampISO}]]`; + return `[[topic:wrote-${langSuffix}, ${relative_path}/post/${encodeURIComponent(post.pid)}, ${post.timestampISO}]]`; + } + + function _encodeURIComponent(value) { + return encodeURIComponent(value); } function isoTimeToLocaleString(isoTime, locale = 'en-GB') { diff --git a/src/activitypub/inbox.js b/src/activitypub/inbox.js index 49c50f4ab1..e224ab1599 100644 --- a/src/activitypub/inbox.js +++ b/src/activitypub/inbox.js @@ -154,7 +154,7 @@ inbox.announce = async (req) => { await topics.events.log(tid, { type: 'announce', uid: actor, - href: `/post/${pid}`, + href: `/post/${encodeURIComponent(pid)}`, pid, timestamp, });