mirror of
https://github.com/misskey-dev/summaly.git
synced 2025-04-29 02:37:27 +09:00
fix: allow legacy allowfullscreen
(#9)
This commit is contained in:
parent
1bab7afee6
commit
5a3321a04f
@ -103,6 +103,9 @@ async function getOEmbedPlayer($, pageUrl) {
|
||||
const allowedPermissions = (iframe.attr('allow') ?? '').split(/\s*;\s*/g)
|
||||
.filter(s => s)
|
||||
.filter(s => !ignoredList.includes(s));
|
||||
if (iframe.attr('allowfullscreen') === '') {
|
||||
allowedPermissions.push('fullscreen');
|
||||
}
|
||||
if (allowedPermissions.some(allow => !safeList.includes(allow))) {
|
||||
// This iframe is probably too powerful to be embedded
|
||||
return null;
|
||||
|
@ -115,6 +115,9 @@ async function getOEmbedPlayer($: cheerio.CheerioAPI, pageUrl: string): Promise<
|
||||
(iframe.attr('allow') ?? '').split(/\s*;\s*/g)
|
||||
.filter(s => s)
|
||||
.filter(s => !ignoredList.includes(s));
|
||||
if (iframe.attr('allowfullscreen') === '') {
|
||||
allowedPermissions.push('fullscreen');
|
||||
}
|
||||
if (allowedPermissions.some(allow => !safeList.includes(allow))) {
|
||||
// This iframe is probably too powerful to be embedded
|
||||
return null;
|
||||
|
@ -294,7 +294,14 @@ describe("oEmbed", () => {
|
||||
await setUpFastify('oembed-allow-fullscreen.json');
|
||||
const summary = await summaly(host);
|
||||
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 () => {
|
||||
|
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