mirror of
https://github.com/affaan-m/ECC.git
synced 2026-10-15 04:35:29 +02:00
fix(docs-governance): audit UNC markdown links
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user