mirror of
https://github.com/misskey-dev/summaly.git
synced 2025-04-29 10:47:25 +09:00
Merge branch 'master' of https://github.com/misskey-dev/summaly
This commit is contained in:
commit
c7d71a9ec2
@ -103,6 +103,9 @@ async function getOEmbedPlayer($, pageUrl) {
|
|||||||
const allowedPermissions = (iframe.attr('allow') ?? '').split(/\s*;\s*/g)
|
const allowedPermissions = (iframe.attr('allow') ?? '').split(/\s*;\s*/g)
|
||||||
.filter(s => s)
|
.filter(s => s)
|
||||||
.filter(s => !ignoredList.includes(s));
|
.filter(s => !ignoredList.includes(s));
|
||||||
|
if (iframe.attr('allowfullscreen') === '') {
|
||||||
|
allowedPermissions.push('fullscreen');
|
||||||
|
}
|
||||||
if (allowedPermissions.some(allow => !safeList.includes(allow))) {
|
if (allowedPermissions.some(allow => !safeList.includes(allow))) {
|
||||||
// This iframe is probably too powerful to be embedded
|
// This iframe is probably too powerful to be embedded
|
||||||
return null;
|
return null;
|
||||||
|
@ -115,6 +115,9 @@ async function getOEmbedPlayer($: cheerio.CheerioAPI, pageUrl: string): Promise<
|
|||||||
(iframe.attr('allow') ?? '').split(/\s*;\s*/g)
|
(iframe.attr('allow') ?? '').split(/\s*;\s*/g)
|
||||||
.filter(s => s)
|
.filter(s => s)
|
||||||
.filter(s => !ignoredList.includes(s));
|
.filter(s => !ignoredList.includes(s));
|
||||||
|
if (iframe.attr('allowfullscreen') === '') {
|
||||||
|
allowedPermissions.push('fullscreen');
|
||||||
|
}
|
||||||
if (allowedPermissions.some(allow => !safeList.includes(allow))) {
|
if (allowedPermissions.some(allow => !safeList.includes(allow))) {
|
||||||
// This iframe is probably too powerful to be embedded
|
// This iframe is probably too powerful to be embedded
|
||||||
return null;
|
return null;
|
||||||
|
@ -294,7 +294,14 @@ describe("oEmbed", () => {
|
|||||||
await setUpFastify('oembed-allow-fullscreen.json');
|
await setUpFastify('oembed-allow-fullscreen.json');
|
||||||
const summary = await summaly(host);
|
const summary = await summaly(host);
|
||||||
expect(summary.player.url).toBe('https://example.com/');
|
expect(summary.player.url).toBe('https://example.com/');
|
||||||
expect(summary.player.allow).toStrictEqual(['fullscreen'])
|
expect(summary.player.allow).toStrictEqual(['fullscreen']);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('allows legacy allowfullscreen', async () => {
|
||||||
|
await setUpFastify('oembed-allow-fullscreen-legacy.json');
|
||||||
|
const summary = await summaly(host);
|
||||||
|
expect(summary.player.url).toBe('https://example.com/');
|
||||||
|
expect(summary.player.allow).toStrictEqual(['fullscreen']);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('allows safelisted permissions', async () => {
|
test('allows safelisted permissions', async () => {
|
||||||
|
7
test/oembed/oembed-allow-fullscreen-legacy.json
Normal file
7
test/oembed/oembed-allow-fullscreen-legacy.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"version": "1.0",
|
||||||
|
"type": "rich",
|
||||||
|
"html": "<iframe src='https://example.com/' allowfullscreen></iframe>",
|
||||||
|
"width": 500,
|
||||||
|
"height": 300
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user