diff --git a/.agents/skills/docs-governance/scripts/markdown_links.py b/.agents/skills/docs-governance/scripts/markdown_links.py index 02ef308ea..239679740 100644 --- a/.agents/skills/docs-governance/scripts/markdown_links.py +++ b/.agents/skills/docs-governance/scripts/markdown_links.py @@ -168,6 +168,7 @@ def markdown_link_targets(text: str) -> list[str]: def normalize_link_target(raw: str) -> str | None: target = raw.strip() + is_unc_path = target.startswith("\\\\") if target.startswith("<"): closing = target.find(">") if closing == -1: @@ -181,7 +182,7 @@ def normalize_link_target(raw: str) -> str | None: if title: target = target[: title.start()] target = unquote(target.split("#", 1)[0].split("?", 1)[0]).replace("\\", "/") - if not target or target.startswith("//"): + if not target or (target.startswith("//") and not is_unc_path): return None if EXTERNAL_URI_RE.match(target): return None diff --git a/skills/docs-governance/scripts/markdown_links.py b/skills/docs-governance/scripts/markdown_links.py index 02ef308ea..239679740 100644 --- a/skills/docs-governance/scripts/markdown_links.py +++ b/skills/docs-governance/scripts/markdown_links.py @@ -168,6 +168,7 @@ def markdown_link_targets(text: str) -> list[str]: def normalize_link_target(raw: str) -> str | None: target = raw.strip() + is_unc_path = target.startswith("\\\\") if target.startswith("<"): closing = target.find(">") if closing == -1: @@ -181,7 +182,7 @@ def normalize_link_target(raw: str) -> str | None: if title: target = target[: title.start()] target = unquote(target.split("#", 1)[0].split("?", 1)[0]).replace("\\", "/") - if not target or target.startswith("//"): + if not target or (target.startswith("//") and not is_unc_path): return None if EXTERNAL_URI_RE.match(target): return None diff --git a/tests/test_docs_governance_audit.py b/tests/test_docs_governance_audit.py index 761c99f16..e66f72370 100644 --- a/tests/test_docs_governance_audit.py +++ b/tests/test_docs_governance_audit.py @@ -128,6 +128,16 @@ def test_artifact_scope_ignores_protocol_relative_external_links(project: Path) assert result.returncode == 0, result.stdout +def test_artifact_scope_checks_unc_style_links(project: Path) -> None: + (project / "guide.md").write_text( + "[missing](\\\\server\\share\\missing.md)\n", encoding="utf-8" + ) + result = run_audit(project, "artifacts") + assert result.returncode == 1 + assert "Broken Markdown link" in result.stdout + assert "//server/share/missing.md" in result.stdout + + def test_artifact_scope_ignores_external_uri_schemes_case_insensitively( project: Path, ) -> None: