3 Commits

Author SHA1 Message Date
c7d71a9ec2 Merge branch 'master' of https://github.com/misskey-dev/summaly 2023-04-20 04:02:59 +00:00
994f420b46 4.0.2 2023-04-20 04:02:55 +00:00
5a3321a04f fix: allow legacy allowfullscreen (#9) 2023-04-20 12:41:11 +09:00
7 changed files with 747 additions and 701 deletions

View File

@ -1,3 +1,7 @@
4.0.2 / 2023-04-20
------------------
* YouTubeをフルスクリーンにできない問題を修正
4.0.1 / 2023-03-16
------------------
* oEmbedの読み込みでエラーが発生した際は、エラーにせずplayerの中身をnullにするように

View File

@ -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;

View File

@ -1,6 +1,6 @@
{
"name": "summaly",
"version": "4.0.1",
"version": "4.0.2",
"description": "Get web page's summary",
"author": "syuilo <syuilotan@yahoo.co.jp>",
"license": "MIT",
@ -9,6 +9,7 @@
"main": "./built/index.js",
"type": "module",
"types": "./built/index.d.ts",
"packageManager": "pnpm@8.3.1",
"files": [
"built",
"LICENSE"
@ -19,17 +20,17 @@
"serve": "fastify start ./built/index.js"
},
"devDependencies": {
"@jest/globals": "^29.4.2",
"@swc/core": "^1.3.35",
"@swc/jest": "^0.2.24",
"@jest/globals": "^29.5.0",
"@swc/core": "^1.3.52",
"@swc/jest": "^0.2.26",
"@types/cheerio": "0.22.18",
"@types/debug": "4.1.7",
"@types/escape-regexp": "^0.0.1",
"@types/node": "16.11.12",
"debug": "^4.3.4",
"fastify": "^4.13.0",
"fastify": "^4.15.0",
"fastify-cli": "^5.7.1",
"jest": "^29.4.2",
"jest": "^29.5.0",
"typescript": "4.5.3"
},
"dependencies": {

1409
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -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;

View File

@ -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 () => {

View File

@ -0,0 +1,7 @@
{
"version": "1.0",
"type": "rich",
"html": "<iframe src='https://example.com/' allowfullscreen></iframe>",
"width": 500,
"height": 300
}