mirror of
https://example.com
synced 2024-11-25 00:16:38 +09:00
fix (backend): stricter hostname checking when fetching remote objects
Co-authored-by: naskya <m@naskya.net>
This commit is contained in:
parent
e8aeaf7d53
commit
0e7ea7edc2
1 changed files with 12 additions and 5 deletions
|
@ -133,14 +133,21 @@ export default class Resolver {
|
|||
throw new Error("invalid response");
|
||||
}
|
||||
|
||||
if (
|
||||
object.id != null &&
|
||||
new URL(finalUrl).host != new URL(object.id).host
|
||||
) {
|
||||
if (object.id == null) return object;
|
||||
if (finalUrl === object.id) return object;
|
||||
|
||||
if (new URL(finalUrl).host !== new URL(object.id).host) {
|
||||
throw new Error("Object ID host doesn't match final url host");
|
||||
}
|
||||
|
||||
return object;
|
||||
const finalRes = await apGet(object.id, this.user);
|
||||
|
||||
if (finalRes.finalUrl !== finalRes.content.id)
|
||||
throw new Error(
|
||||
"Object ID still doesn't match final URL after second fetch attempt",
|
||||
);
|
||||
|
||||
return finalRes.content;
|
||||
}
|
||||
|
||||
private async resolveLocal(url: string): Promise<IObject> {
|
||||
|
|
Loading…
Reference in a new issue