Skip to content
Snippets Groups Projects
Commit c94f6994 authored by Julia's avatar Julia
Browse files

merge: Only accept HTML `<link rel="alternate">` on successful HTTP statuses (!633)

View MR for information: TransFem-org/Sharkey!633



Approved-by: default avatardakkar <dakkar@thenautilus.net>
Approved-by: default avatarTess K <me@thvxl.se>
Approved-by: default avatarfEmber <acomputerdog@gmail.com>
Approved-by: default avatarMarie <github@yuugi.dev>
parents 30c1c7c2 e4cbd588
No related branches found
No related tags found
No related merge requests found
......@@ -207,7 +207,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 = new Window({
settings: {
......@@ -242,6 +246,8 @@ export class ApRequestService {
}
} catch (e) {
// something went wrong parsing the HTML, ignore the whole thing
} finally {
await window.happyDOM.close();
}
}
//#endregion
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment