Fix: <link rel="alternate">を追って照会するのはOKレスポンスが返却された場合のみに (#14627)

* Only accept HTML `<link rel="alternate">` on success

(cherry picked from commit 6ea48be84a)

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

(cherry picked from commit b667a68bd4)

* jsdomに戻す

* Update Changelog

* Revert "jsdomに戻す"

This reverts commit c03603611b74d16df52e77e44c558e958a82f3f4.

* 🎨

---------

Co-authored-by: Julia Johannesen <julia@insertdomain.name>
This commit is contained in:
かっこかり 2024-09-25 12:31:37 +09:00 committed by GitHub
parent 53682f5cc6
commit dd124a8aed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View File

@ -38,6 +38,8 @@
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/commit/8a982c61c01909e7540ff1be9f019df07c3f0624) (Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/commit/8a982c61c01909e7540ff1be9f019df07c3f0624)
- Fix: サーバーサイドのDOM解析完了時にリソースを開放するように - Fix: サーバーサイドのDOM解析完了時にリソースを開放するように
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/634) (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 ## 2024.8.0

View File

@ -205,7 +205,11 @@ export class ApRequestService {
//#region リクエスト先がhtmlかつactivity+jsonへのalternate linkタグがあるとき //#region リクエスト先がhtmlかつactivity+jsonへのalternate linkタグがあるとき
const contentType = res.headers.get('content-type'); 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 html = await res.text();
const { window, happyDOM } = new Window({ const { window, happyDOM } = new Window({
settings: { settings: {