mirror of
https://github.com/AgriciDaniel/claude-seo.git
synced 2026-11-25 07:30:08 +01:00
The new PowerShell 5.1 smoke job caught a real bug: uninstall.ps1 used the three-argument Join-Path form that only PowerShell 7 accepts, so 5.1 users could not uninstall. Both calls are nested now. The Windows full-suite leg caught three test-side issues: the Banana setup test pointed HOME at a temp dir but Path.home() reads USERPROFILE on Windows; the CJK content-quality test encoded its input with the locale codec; and the schema-hook detection tests decoded the hook's UTF-8 emoji output with cp1252, which on Windows fails inside the pipe reader thread and leaves stdout as None. content_quality.py also reconfigures its streams to UTF-8 so Windows consoles can carry CJK text. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015qjDbqj88SjLGY4MdQKGB8
28 lines
1023 B
Python
28 lines
1023 B
Python
"""The JSON-LD hook must not hang on adversarial script tags (v2.3.0 review)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
HOOK = Path(__file__).resolve().parents[1] / "hooks" / "validate-schema.py"
|
|
|
|
|
|
def test_unclosed_script_tag_with_many_apostrophes_finishes_quickly(tmp_path: Path) -> None:
|
|
# A tag with many apostrophes and no closing </script> made the attribute
|
|
# tokenizer backtrack exponentially before the fallback class excluded quotes.
|
|
page = tmp_path / "partial.php"
|
|
page.write_text("<html><body>\n<script " + ("'" * 80) + " type=\"application/ld+json\"\n", encoding="utf-8")
|
|
started = time.monotonic()
|
|
result = subprocess.run(
|
|
[sys.executable, str(HOOK), str(page)],
|
|
capture_output=True,
|
|
encoding="utf-8",
|
|
errors="replace",
|
|
timeout=20,
|
|
)
|
|
assert time.monotonic() - started < 5, "hook took too long: possible catastrophic backtracking"
|
|
assert result.returncode in (0, 1, 2)
|