Skip to content

Commit

Permalink
Iframely rel review (#545)
Browse files Browse the repository at this point in the history
* use `html-meta.iframely` to check `iframely` rel

* rename `isAllowedApp` to `isAllowed`
  • Loading branch information
nleush authored Jul 9, 2024
1 parent b0fa073 commit a5d7c38
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plugins/links/iframely-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 13 additions & 2 deletions plugins/links/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <link rel="iframely" ....
Expand Down Expand Up @@ -121,9 +125,16 @@ export default {
// Apply whitelist except for thumbnails.
if (rels.indexOf(CONFIG.R.thumbnail) === -1 && rels.indexOf(CONFIG.R.icon) === -1 && rels.indexOf(CONFIG.R.logo) === -1) {
var tags = whitelistRecord.getQATags(rels);
if (tags.indexOf('allow') === -1) {
var isAllowedByRels = tags.indexOf('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 = [];
Expand Down

0 comments on commit a5d7c38

Please sign in to comment.