From 27320344470f7c2457216ab64eecb5e513417ac4 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Sat, 29 Nov 2025 19:16:05 +0900 Subject: perf(backend): jsdom、happy-domをやめて軽量な実装にし、メモリ削減・高速化 (#16885) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * wip * Update packages/backend/src/server/api/endpoints/i/update.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update packages/backend/src/core/FetchInstanceMetadataService.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * remove some packages * コミット漏れ * clean up * fix * Update MfmService.ts * fix * fix * Update MfmService.ts * wip * rename * Update packages/backend/src/core/MfmService.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update packages/backend/src/core/MfmService.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update packages/backend/src/core/MfmService.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update packages/backend/src/core/MfmService.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update packages/backend/src/core/activitypub/ApRendererService.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update packages/backend/src/core/MfmService.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update packages/backend/src/core/MfmService.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update MfmService.ts * Update CHANGELOG.md --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- packages/backend/src/server/web/ClientServerService.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'packages/backend/src/server/web/ClientServerService.ts') diff --git a/packages/backend/src/server/web/ClientServerService.ts b/packages/backend/src/server/web/ClientServerService.ts index f9d904f3cd..fef6a27087 100644 --- a/packages/backend/src/server/web/ClientServerService.ts +++ b/packages/backend/src/server/web/ClientServerService.ts @@ -15,7 +15,6 @@ import fastifyStatic from '@fastify/static'; import fastifyView from '@fastify/view'; import fastifyProxy from '@fastify/http-proxy'; import vary from 'vary'; -import htmlSafeJsonStringify from 'htmlescape'; import type { Config } from '@/config.js'; import { getNoteSummary } from '@/misc/get-note-summary.js'; import { DI } from '@/di-symbols.js'; @@ -63,6 +62,20 @@ const frontendViteOut = `${_dirname}/../../../../../built/_frontend_vite_/`; const frontendEmbedViteOut = `${_dirname}/../../../../../built/_frontend_embed_vite_/`; const tarball = `${_dirname}/../../../../../built/tarball/`; +const ESCAPE_LOOKUP = { + '&': '\\u0026', + '>': '\\u003e', + '<': '\\u003c', + '\u2028': '\\u2028', + '\u2029': '\\u2029', +} as Record; + +const ESCAPE_REGEX = /[&><\u2028\u2029]/g; + +function htmlSafeJsonStringify(obj: any): string { + return JSON.stringify(obj).replace(ESCAPE_REGEX, x => ESCAPE_LOOKUP[x]); +} + @Injectable() export class ClientServerService { private logger: Logger; -- cgit v1.2.3-freya