mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-26 16:41:21 +01:00
fix: #13170, remove mime-type and regex test for "Emoji" attachment, wrap tag name in colons if not provided
This commit is contained in:
@@ -11,8 +11,6 @@ const privileges = require('../privileges');
|
|||||||
const activitypub = require('../activitypub');
|
const activitypub = require('../activitypub');
|
||||||
const utils = require('../utils');
|
const utils = require('../utils');
|
||||||
|
|
||||||
const isEmojiShortcode = /^:[\w]+:$/;
|
|
||||||
|
|
||||||
module.exports = function (Posts) {
|
module.exports = function (Posts) {
|
||||||
Posts.create = async function (data) {
|
Posts.create = async function (data) {
|
||||||
// This is an internal method, consider using Topics.reply instead
|
// This is an internal method, consider using Topics.reply instead
|
||||||
@@ -54,9 +52,15 @@ module.exports = function (Posts) {
|
|||||||
if (_activitypub && _activitypub.tag && Array.isArray(_activitypub.tag)) {
|
if (_activitypub && _activitypub.tag && Array.isArray(_activitypub.tag)) {
|
||||||
_activitypub.tag
|
_activitypub.tag
|
||||||
.filter(tag => tag.type === 'Emoji' &&
|
.filter(tag => tag.type === 'Emoji' &&
|
||||||
isEmojiShortcode.test(tag.name) &&
|
tag.icon && tag.icon.type === 'Image')
|
||||||
tag.icon && tag.icon.mediaType && tag.icon.mediaType.startsWith('image/'))
|
|
||||||
.forEach((tag) => {
|
.forEach((tag) => {
|
||||||
|
if (!tag.name.startsWith(':')) {
|
||||||
|
tag.name = `:${tag.name}`;
|
||||||
|
}
|
||||||
|
if (!tag.name.endsWith(':')) {
|
||||||
|
tag.name = `${tag.name}:`;
|
||||||
|
}
|
||||||
|
|
||||||
postData.content = postData.content.replace(new RegExp(tag.name, 'g'), `<img class="not-responsive emoji" src="${tag.icon.url}" title="${tag.name}" />`);
|
postData.content = postData.content.replace(new RegExp(tag.name, 'g'), `<img class="not-responsive emoji" src="${tag.icon.url}" title="${tag.name}" />`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user