Skip to content

Commit

Permalink
Fix: <link rel="alternate">を追って照会するのはOKレスポンスが返却された場合のみに (#14627)
Browse files Browse the repository at this point in the history
* Only accept HTML `<link rel="alternate">` on success

(cherry picked from commit 6ea48be)

* Use `res.ok` instead of 200-299

(cherry picked from commit b667a68)

* jsdomに戻す

* Update Changelog

* Revert "jsdomに戻す"

This reverts commit c036036.

* 🎨

---------

Co-authored-by: Julia Johannesen <[email protected]>
  • Loading branch information
kakkokari-gtyih and K4rakara authored Sep 25, 2024
1 parent 53682f5 commit dd124a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<link rel="alternate">`を追って照会するのはOKレスポンスが返却された場合のみに
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/633)

## 2024.8.0

Expand Down
6 changes: 5 additions & 1 deletion packages/backend/src/core/activitypub/ApRequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit dd124a8

Please sign in to comment.