mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-13 04:26:16 -08:00
fix(agents): validate iframe document references
This commit is contained in:
1 parent
82d582bb74
commit
5da10082e5
3 files changed
+31
-4
No files matched your search
@@ -57,6 +57,7 @@ Only headings present outside inert HTML containers contribute slugs or duplicat
|
||||
Explicit HTML anchors use `parse5`, excluding comments, scripts, styles and template contents.
|
||||
Rendered HTML anchor and image-map area hrefs and image sources use the same local-reference checks
|
||||
as Markdown links, including decoded attributes and fragment validation.
|
||||
Iframe sources are document references and retain Markdown-target anchor checks.
|
||||
Image references check file existence without interpreting image fragments as
|
||||
Markdown headings; document links keep anchor checks even when sharing a target.
|
||||
HTML video, audio, source and track `src` assets and video posters use the same
|
||||
|
||||
@@ -71,15 +71,20 @@ function htmlNavigation(html, inspect = () => {}) {
|
||||
if (
|
||||
(['a', 'area'].includes(node.tagName) &&
|
||||
attribute.name === 'href') ||
|
||||
(['img', 'video', 'audio', 'source', 'track'].includes(
|
||||
node.tagName
|
||||
) &&
|
||||
([
|
||||
'img',
|
||||
'video',
|
||||
'audio',
|
||||
'source',
|
||||
'track',
|
||||
'iframe',
|
||||
].includes(node.tagName) &&
|
||||
attribute.name === 'src') ||
|
||||
(node.tagName === 'video' && attribute.name === 'poster')
|
||||
)
|
||||
references.push({
|
||||
target: attribute.value,
|
||||
image: !['a', 'area'].includes(node.tagName),
|
||||
image: !['a', 'area', 'iframe'].includes(node.tagName),
|
||||
});
|
||||
if (
|
||||
['img', 'source'].includes(node.tagName) &&
|
||||
|
||||
@@ -1170,3 +1170,24 @@ for (const suffix of [',then', ';then', ':then', '!then', '?then']) {
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
for (const target of ['docs/missing.html', 'docs/example.md#missing']) {
|
||||
test(`iframe document target is validated: ${target}`, async (t) => {
|
||||
assert.ok(
|
||||
(
|
||||
await diagnostics(t, {
|
||||
'AGENTS.md': `<iframe src="${target}"></iframe>`,
|
||||
})
|
||||
).length > 0
|
||||
);
|
||||
});
|
||||
}
|
||||
test('valid iframe and inert iframe targets pass', async (t) => {
|
||||
assert.deepEqual(
|
||||
await diagnostics(t, {
|
||||
'AGENTS.md':
|
||||
'<iframe src="docs/example.md#repeat"></iframe>\n<template><iframe src="missing.html"></iframe></template>',
|
||||
}),
|
||||
[]
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user