From a5d7c38784af88b7dbcf71942f3dd1ccc01213a7 Mon Sep 17 00:00:00 2001 From: Nazar Leush <39333+nleush@users.noreply.github.com> Date: Tue, 9 Jul 2024 21:02:44 +0300 Subject: [PATCH] Iframely rel review (#545) * use `html-meta.iframely` to check `iframely` rel * rename `isAllowedApp` to `isAllowed` --- plugins/links/iframely-link.js | 2 +- plugins/links/utils.js | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/plugins/links/iframely-link.js b/plugins/links/iframely-link.js index 02958a9c4..66aabd749 100644 --- a/plugins/links/iframely-link.js +++ b/plugins/links/iframely-link.js @@ -16,7 +16,7 @@ export default { } for (const [key, value] of Object.entries(meta)) { - if (key.indexOf(appname) === 0 || !ignoreIframely && key.indexOf(CONFIG.R.iframely) === 0) { + if (key.indexOf(appname) === 0 || (!ignoreIframely && key.indexOf(CONFIG.R.iframely) === 0)) { links = links.concat( utils.parseMetaLinks( key, diff --git a/plugins/links/utils.js b/plugins/links/utils.js index 7d2d52d48..631d67e29 100644 --- a/plugins/links/utils.js +++ b/plugins/links/utils.js @@ -90,8 +90,12 @@ export default { // Filter empty. rels = rels.filter(i => i); + var isAllowed = whitelistRecord.isAllowed('html-meta.iframely') // New check. + || whitelistRecord.isAllowed('iframely.app'); // Old check + + // If no additional rels specified, try add 'app'. if (!rels.some(rel => CONFIG.REL_GROUPS && CONFIG.REL_GROUPS.includes(rel))) { - if (whitelistRecord.isAllowed('iframely.app') + if (isAllowed && /iframely/i.test(key) || (appname && key.indexOf(appname) === 0)) { // Allow -1; + + if (!isAllowed && !isAllowedByRels) { return []; } + + // Add resizable rel. + if (rels.indexOf(CONFIG.R.resizable) === -1 && whitelistRecord.isAllowed('html-meta.iframely', CONFIG.R.resizable)) { + rels.push(CONFIG.R.resizable); + } } var links = [];