mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-13 04:26:16 -08:00
fix(agents): validate document formats and trim HTML URLs
This commit is contained in:
1 parent
8f76a2c456
commit
a2d1997e29
4 files changed
+36
-3
No files matched your search
@@ -83,7 +83,10 @@ function htmlNavigation(html, inspect = () => {}) {
|
||||
(node.tagName === 'video' && attribute.name === 'poster')
|
||||
)
|
||||
references.push({
|
||||
target: attribute.value,
|
||||
target: attribute.value.replace(
|
||||
/^[\u0000-\u0020]+|[\u0000-\u0020]+$/gu,
|
||||
''
|
||||
),
|
||||
image: !['a', 'area', 'iframe'].includes(node.tagName),
|
||||
});
|
||||
if (
|
||||
|
||||
@@ -130,7 +130,9 @@ async function packageMentions(rootDir) {
|
||||
if (
|
||||
/%[\da-f]{2}/iu.test(token) ||
|
||||
MARKDOWN_EXTENSION.test(path) ||
|
||||
/\.(?:txt|json|ya?ml|html?|rst|rest|adoc|asciidoc)$/iu.test(path)
|
||||
/\.(?:txt|json|ya?ml|html?|rst|rest|adoc|asciidoc|pdf|docx?|odt|rtf|org|tex)$/iu.test(
|
||||
path
|
||||
)
|
||||
)
|
||||
return false;
|
||||
if (packages.includes(token)) return true;
|
||||
|
||||
@@ -1266,3 +1266,29 @@ for (const extension of ['rst', 'rest', 'adoc', 'asciidoc']) {
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
for (const extension of ['pdf', 'doc', 'docx', 'odt', 'rtf', 'org', 'tex']) {
|
||||
test(`document format is not a package exemption: ${extension}`, async (t) => {
|
||||
assert.ok(
|
||||
(
|
||||
await diagnostics(t, {
|
||||
'package.json': JSON.stringify({
|
||||
dependencies: { '@angular/core': '*' },
|
||||
}),
|
||||
'CLAUDE.md':
|
||||
'@AGENTS.md\n\nRead @angular/core/docs/guide.' +
|
||||
extension,
|
||||
})
|
||||
).some((message) => message.includes('additional or inline'))
|
||||
);
|
||||
});
|
||||
}
|
||||
for (const html of [
|
||||
'<a href=" docs/example.md#repeat ">Guide</a>',
|
||||
'<iframe src="	docs/example.md "></iframe>',
|
||||
'<img src=" docs/example.md ">',
|
||||
]) {
|
||||
test(`HTML URL edge whitespace is ignored: ${html}`, async (t) => {
|
||||
assert.deepEqual(await diagnostics(t, { 'AGENTS.md': html }), []);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user