Skip to content

Node.js based forum software built for the modern web

fix: #12912, strip custom emoji from remote content titles

Julian Lam7adc3140e257
diff --git a/src/activitypub/notes.js b/src/activitypub/notes.js
index 6574465dbf..cfe0b1db9e 100644
--- a/src/activitypub/notes.js
+++ b/src/activitypub/notes.js
@@ -110,6 +110,15 @@ Notes.assert = async (uid, input, options = { skipChecks: false }) => {
// mainPid ok to leave as-is
title = name || activitypub.helpers.generateTitle(utils.decodeHTMLEntities(content));
+
+ // Remove any custom emoji from title
+ if (_activitypub && _activitypub.tag && Array.isArray(_activitypub.tag)) {
+ _activitypub.tag
+ .filter(tag => tag.type === 'Emoji')
+ .forEach((tag) => {
+ title = title.replace(new RegExp(tag.name, 'g'), '');
+ });
+ }
}
mainPid = utils.isNumber(mainPid) ? parseInt(mainPid, 10) : mainPid;