From 18370a24c61538293547dbbb8cdd305d9cc12368 Mon Sep 17 00:00:00 2001 From: tai-cha Date: Sat, 17 Aug 2024 18:59:21 +0900 Subject: [PATCH 1/3] fix(backend): contenttype detection of html in signedGet --- packages/backend/src/core/activitypub/ApRequestService.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/backend/src/core/activitypub/ApRequestService.ts b/packages/backend/src/core/activitypub/ApRequestService.ts index 3d1bd4464871..212f505ce82f 100644 --- a/packages/backend/src/core/activitypub/ApRequestService.ts +++ b/packages/backend/src/core/activitypub/ApRequestService.ts @@ -204,8 +204,7 @@ export class ApRequestService { //#region リクエスト先がhtmlかつactivity+jsonへのalternate linkタグがあるとき const contentType = res.headers.get('content-type'); - - if ((contentType === 'text/html' || contentType?.startsWith('text/html;')) && _followAlternate === true) { + if (contentType?.split(';')[0]?.trimEnd()?.toLowerCase() === 'text/html' && _followAlternate === true) { const html = await res.text(); const window = new Window(); const document = window.document; From 7c89929e1229f93a7c18dcd667777f10ed82c2df Mon Sep 17 00:00:00 2001 From: tai-cha Date: Sat, 17 Aug 2024 19:30:06 +0900 Subject: [PATCH 2/3] code style --- packages/backend/src/core/activitypub/ApRequestService.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/backend/src/core/activitypub/ApRequestService.ts b/packages/backend/src/core/activitypub/ApRequestService.ts index 212f505ce82f..eb9059ba0911 100644 --- a/packages/backend/src/core/activitypub/ApRequestService.ts +++ b/packages/backend/src/core/activitypub/ApRequestService.ts @@ -204,6 +204,7 @@ export class ApRequestService { //#region リクエスト先がhtmlかつactivity+jsonへのalternate linkタグがあるとき const contentType = res.headers.get('content-type'); + if (contentType?.split(';')[0]?.trimEnd()?.toLowerCase() === 'text/html' && _followAlternate === true) { const html = await res.text(); const window = new Window(); From f94e3d9b6fc33638ea4747f982431be4224800d0 Mon Sep 17 00:00:00 2001 From: tai-cha Date: Sat, 17 Aug 2024 19:46:17 +0900 Subject: [PATCH 3/3] fix by review --- packages/backend/src/core/activitypub/ApRequestService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend/src/core/activitypub/ApRequestService.ts b/packages/backend/src/core/activitypub/ApRequestService.ts index eb9059ba0911..7cf8359212c1 100644 --- a/packages/backend/src/core/activitypub/ApRequestService.ts +++ b/packages/backend/src/core/activitypub/ApRequestService.ts @@ -205,7 +205,7 @@ export class ApRequestService { //#region リクエスト先がhtmlかつactivity+jsonへのalternate linkタグがあるとき const contentType = res.headers.get('content-type'); - if (contentType?.split(';')[0]?.trimEnd()?.toLowerCase() === 'text/html' && _followAlternate === true) { + if ((contentType ?? '').split(';')[0].trimEnd().toLowerCase() === 'text/html' && _followAlternate === true) { const html = await res.text(); const window = new Window(); const document = window.document;