fix(backend): happy-domで外部HTMLをパースする際に関連リソースが読み込まれる問題を修正 (#14521)
cherry picked from commit be0906a6c73726ed02a358bcbe904fa3d99713ea Co-authored-by: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com>
This commit is contained in:
parent
9e998cc10b
commit
c441c4728f
1 changed files with 10 additions and 6 deletions
|
@ -206,6 +206,7 @@ export class ApRequestService {
|
||||||
|
|
||||||
if ((contentType ?? '').split(';')[0].trimEnd().toLowerCase() === 'text/html' && _followAlternate) {
|
if ((contentType ?? '').split(';')[0].trimEnd().toLowerCase() === 'text/html' && _followAlternate) {
|
||||||
const html = await res.text();
|
const html = await res.text();
|
||||||
|
try {
|
||||||
const fragment = JSDOM.fragment(html);
|
const fragment = JSDOM.fragment(html);
|
||||||
|
|
||||||
const alternate = fragment.querySelector('head > link[rel="alternate"][type="application/activity+json"]');
|
const alternate = fragment.querySelector('head > link[rel="alternate"][type="application/activity+json"]');
|
||||||
|
@ -215,6 +216,9 @@ export class ApRequestService {
|
||||||
return await this.signedGet(href, user, false);
|
return await this.signedGet(href, user, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// something went wrong parsing the HTML, ignore the whole thing
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue