From bf9da8458cdd915aa2d6d3ca2133c0d43113f49f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Fri, 27 Sep 2019 05:16:59 +0900 Subject: [PATCH] Limit the tag counts to 100 (#5263) * Limit the tag counts to 256 * Update create.ts * Update create.ts * Update create.ts * Limit the user tag --- src/remote/activitypub/models/person.ts | 4 ++-- src/server/api/endpoints/i/update.ts | 2 +- src/services/note/create.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/remote/activitypub/models/person.ts b/src/remote/activitypub/models/person.ts index a0b951c5f..1c674729c 100644 --- a/src/remote/activitypub/models/person.ts +++ b/src/remote/activitypub/models/person.ts @@ -134,7 +134,7 @@ export async function createPerson(uri: string, resolver?: Resolver): Promise tag.toLowerCase()); + const tags = extractHashtags(person.tag).map(tag => tag.toLowerCase()).splice(0, 100); const isBot = object.type == 'Service'; @@ -307,7 +307,7 @@ export async function updatePerson(uri: string, resolver?: Resolver | null, hint const { fields, services } = analyzeAttachments(person.attachment || []); - const tags = extractHashtags(person.tag).map(tag => tag.toLowerCase()); + const tags = extractHashtags(person.tag).map(tag => tag.toLowerCase()).splice(0, 100); const updates = { lastFetchedAt: new Date(), diff --git a/src/server/api/endpoints/i/update.ts b/src/server/api/endpoints/i/update.ts index 91056f04a..99f7efbe1 100644 --- a/src/server/api/endpoints/i/update.ts +++ b/src/server/api/endpoints/i/update.ts @@ -257,7 +257,7 @@ export default define(meta, async (ps, user, app) => { if (newDescription != null) { const tokens = parse(newDescription); emojis = emojis.concat(extractEmojis(tokens!)); - tags = extractHashtags(tokens!).map(tag => tag.toLowerCase()); + tags = extractHashtags(tokens!).map(tag => tag.toLowerCase()).splice(0, 100); } updates.emojis = emojis; diff --git a/src/services/note/create.ts b/src/services/note/create.ts index fcf991793..0bb6cc1f5 100644 --- a/src/services/note/create.ts +++ b/src/services/note/create.ts @@ -165,7 +165,7 @@ export default async (user: User, data: Option, silent = false) => new Promise Array.from(tag || '').length <= 128); + tags = tags.filter(tag => Array.from(tag || '').length <= 128).splice(0, 100); if (data.reply && (user.id !== data.reply.userId) && !mentionedUsers.some(u => u.id === data.reply!.userId)) { mentionedUsers.push(await Users.findOne(data.reply.userId).then(ensure));