From dd124a8aedb34a1112405fa68bd5daaa96fdc882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=93=E3=81=8B=E3=82=8A?= <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Wed, 25 Sep 2024 12:31:37 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20``=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E3=81=A3=E3=81=A6=E7=85=A7=E4=BC=9A=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=81=AE=E3=81=AFOK=E3=83=AC=E3=82=B9=E3=83=9D=E3=83=B3?= =?UTF-8?q?=E3=82=B9=E3=81=8C=E8=BF=94=E5=8D=B4=E3=81=95=E3=82=8C=E3=81=9F?= =?UTF-8?q?=E5=A0=B4=E5=90=88=E3=81=AE=E3=81=BF=E3=81=AB=20(#14627)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Only accept HTML `` on success (cherry picked from commit 6ea48be84abdab66301a957c27dd5d84886dfb36) * Use `res.ok` instead of 200-299 (cherry picked from commit b667a68bd4eb916084658592d2942d521950005b) * jsdomに戻す * Update Changelog * Revert "jsdomに戻す" This reverts commit c03603611b74d16df52e77e44c558e958a82f3f4. * :art: --------- Co-authored-by: Julia Johannesen --- CHANGELOG.md | 2 ++ packages/backend/src/core/activitypub/ApRequestService.ts | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd43344b6..046dab073 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,8 @@ (Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/commit/8a982c61c01909e7540ff1be9f019df07c3f0624) - Fix: サーバーサイドのDOM解析完了時にリソースを開放するように (Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/634) +- Fix: ``を追って照会するのはOKレスポンスが返却された場合のみに + (Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/633) ## 2024.8.0 diff --git a/packages/backend/src/core/activitypub/ApRequestService.ts b/packages/backend/src/core/activitypub/ApRequestService.ts index 7c78f3319..c7d19adfd 100644 --- a/packages/backend/src/core/activitypub/ApRequestService.ts +++ b/packages/backend/src/core/activitypub/ApRequestService.ts @@ -205,7 +205,11 @@ 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 ( + res.ok && + (contentType ?? '').split(';')[0].trimEnd().toLowerCase() === 'text/html' && + _followAlternate === true + ) { const html = await res.text(); const { window, happyDOM } = new Window({ settings: {