From 3a7e8cfe5097f867d978e1a59f677030ee92c5f0 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Sat, 11 Feb 2023 19:16:28 +0100 Subject: [PATCH] server: check instance description length limit Changelog: Fixed --- packages/backend/src/services/fetch-instance-metadata.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/services/fetch-instance-metadata.ts b/packages/backend/src/services/fetch-instance-metadata.ts index ad312c3c8..71eb3269a 100644 --- a/packages/backend/src/services/fetch-instance-metadata.ts +++ b/packages/backend/src/services/fetch-instance-metadata.ts @@ -246,19 +246,20 @@ async function getSiteName(info: NodeInfo | null, doc: DOMWindow['document'] | n async function getDescription(info: NodeInfo | null, doc: DOMWindow['document'] | null, manifest: Record | null): Promise { if (info && info.metadata) { - if (info.metadata.nodeDescription || info.metadata.description) { - return info.metadata.nodeDescription || info.metadata.description; + const description = info.metadata.nodeDescription || info.metadata.description; + if (description && description.length < 4096) { + return description; } } if (doc) { const meta = doc.querySelector('meta[name="description"]')?.getAttribute('content'); - if (meta) { + if (meta && meta.length < 4096) { return meta; } const og = doc.querySelector('meta[property="og:description"]')?.getAttribute('content'); - if (og) { + if (og && og.length < 4096) { return og; } }