2025.2.1-beta.0のlintがコケているのを修正 (#15546)
This commit is contained in:
parent
9a619c621d
commit
426940bea7
@ -34,7 +34,7 @@ export enum FetchAllowSoftFailMask {
|
|||||||
// Allow all softfail flags
|
// Allow all softfail flags
|
||||||
//
|
//
|
||||||
// do not use this flag on released code
|
// do not use this flag on released code
|
||||||
Any = ~0
|
Any = ~0,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,7 +78,7 @@ function normalizeSynonymousSubdomain(url: URL | string): URL {
|
|||||||
export function assertActivityMatchesUrls(requestUrl: string | URL, activity: IObject, candidateUrls: (string | URL)[], allowSoftfail: FetchAllowSoftFailMask): FetchAllowSoftFailMask {
|
export function assertActivityMatchesUrls(requestUrl: string | URL, activity: IObject, candidateUrls: (string | URL)[], allowSoftfail: FetchAllowSoftFailMask): FetchAllowSoftFailMask {
|
||||||
// must have a unique identifier to verify authority
|
// must have a unique identifier to verify authority
|
||||||
if (!activity.id) {
|
if (!activity.id) {
|
||||||
throw new Error(`bad Activity: missing id field`);
|
throw new Error('bad Activity: missing id field');
|
||||||
}
|
}
|
||||||
|
|
||||||
let softfail = 0;
|
let softfail = 0;
|
||||||
@ -90,7 +90,7 @@ export function assertActivityMatchesUrls(requestUrl: string | URL, activity: IO
|
|||||||
}
|
}
|
||||||
|
|
||||||
softfail |= needed;
|
softfail |= needed;
|
||||||
}
|
};
|
||||||
|
|
||||||
const requestUrlParsed = normalizeSynonymousSubdomain(requestUrl);
|
const requestUrlParsed = normalizeSynonymousSubdomain(requestUrl);
|
||||||
const idParsed = normalizeSynonymousSubdomain(activity.id);
|
const idParsed = normalizeSynonymousSubdomain(activity.id);
|
||||||
@ -100,27 +100,27 @@ export function assertActivityMatchesUrls(requestUrl: string | URL, activity: IO
|
|||||||
const requestUrlSecure = requestUrlParsed.protocol === 'https:';
|
const requestUrlSecure = requestUrlParsed.protocol === 'https:';
|
||||||
const finalUrlSecure = candidateUrlsParsed.every(it => it.protocol === 'https:');
|
const finalUrlSecure = candidateUrlsParsed.every(it => it.protocol === 'https:');
|
||||||
if (requestUrlSecure && !finalUrlSecure) {
|
if (requestUrlSecure && !finalUrlSecure) {
|
||||||
throw new Error(`bad Activity: id(${activity?.id}) is not allowed to have http:// in the url`);
|
throw new Error(`bad Activity: id(${activity.id}) is not allowed to have http:// in the url`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare final URL to the ID
|
// Compare final URL to the ID
|
||||||
if (!candidateUrlsParsed.some(it => it.href === idParsed.href)) {
|
if (!candidateUrlsParsed.some(it => it.href === idParsed.href)) {
|
||||||
requireSoftfail(FetchAllowSoftFailMask.NonCanonicalId, `bad Activity: id(${activity?.id}) does not match response url(${candidateUrlsParsed.map(it => it.toString())})`);
|
requireSoftfail(FetchAllowSoftFailMask.NonCanonicalId, `bad Activity: id(${activity.id}) does not match response url(${candidateUrlsParsed.map(it => it.toString())})`);
|
||||||
|
|
||||||
// at lease host need to match exactly (ActivityPub requirement)
|
// at lease host need to match exactly (ActivityPub requirement)
|
||||||
if (!candidateUrlsParsed.some(it => idParsed.host === it.host)) {
|
if (!candidateUrlsParsed.some(it => idParsed.host === it.host)) {
|
||||||
throw new Error(`bad Activity: id(${activity?.id}) does not match response host(${candidateUrlsParsed.map(it => it.host)})`);
|
throw new Error(`bad Activity: id(${activity.id}) does not match response host(${candidateUrlsParsed.map(it => it.host)})`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compare request URL to the ID
|
// Compare request URL to the ID
|
||||||
if (!requestUrlParsed.href.includes(idParsed.href)) {
|
if (!requestUrlParsed.href.includes(idParsed.href)) {
|
||||||
requireSoftfail(FetchAllowSoftFailMask.NonCanonicalId, `bad Activity: id(${activity?.id}) does not match request url(${requestUrlParsed.toString()})`);
|
requireSoftfail(FetchAllowSoftFailMask.NonCanonicalId, `bad Activity: id(${activity.id}) does not match request url(${requestUrlParsed.toString()})`);
|
||||||
|
|
||||||
// if cross-origin lookup is allowed, we can accept some variation between the original request URL to the final object ID (but not between the final URL and the object ID)
|
// if cross-origin lookup is allowed, we can accept some variation between the original request URL to the final object ID (but not between the final URL and the object ID)
|
||||||
const hostResult = hostFuzzyMatch(requestUrlParsed.host, idParsed.host);
|
const hostResult = hostFuzzyMatch(requestUrlParsed.host, idParsed.host);
|
||||||
|
|
||||||
requireSoftfail(hostResult, `bad Activity: id(${activity?.id}) is valid but is not the same origin as request url(${requestUrlParsed.toString()})`);
|
requireSoftfail(hostResult, `bad Activity: id(${activity.id}) is valid but is not the same origin as request url(${requestUrlParsed.toString()})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return softfail;
|
return softfail;
|
||||||
|
@ -397,7 +397,7 @@ describe('Timelines', () => {
|
|||||||
assert.strictEqual(res.body.some(note => note.id === bobNote2.id), true);
|
assert.strictEqual(res.body.some(note => note.id === bobNote2.id), true);
|
||||||
assert.strictEqual(res.body.some(note => note.id === carolNote1.id), false);
|
assert.strictEqual(res.body.some(note => note.id === carolNote1.id), false);
|
||||||
assert.strictEqual(res.body.some(note => note.id === carolNote2.id), false);
|
assert.strictEqual(res.body.some(note => note.id === carolNote2.id), false);
|
||||||
}, 1000 * 15);
|
}, 1000 * 30);
|
||||||
|
|
||||||
test.concurrent('フォローしているユーザーのチャンネル投稿が含まれない', async () => {
|
test.concurrent('フォローしているユーザーのチャンネル投稿が含まれない', async () => {
|
||||||
const [alice, bob] = await Promise.all([signup(), signup()]);
|
const [alice, bob] = await Promise.all([signup(), signup()]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user