You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sync_from_registry.py crashes on backslashes and does not escape JSON embedded in script tags #106
scripts/sync_from_registry.py regenerates the README, CLAUDE.md and docs/index.html from registry.json, and a required CI check depends on it. Two escaping bugs let ordinary registry content crash the sync or corrupt the generated output.
Evidence
Replacement string treated as a regex template.
scripts/sync_from_registry.py:323 calls pattern.sub(replacement, text, count=1) with a plain string, so backslash sequences in generated content are interpreted.
Reproduced: a body containing C:\dev raises bad escape \d, and \1 would silently insert a captured group.
Sibling helpers in the same file already pass a lambda.
JSON in <script> not escaped.
render_embedded_registry (:215) and render_search_index (:296) write json.dumps(...) straight into <script type="application/json">.
A registry string containing a closing script tag ends the block early. That breaks the page, weakens the "no unsafe DOM sinks" posture in CLAUDE.md, and breaks the next sync run, because the replace_script_block regex stops at the first closing tag.
Registry content is maintainer-reviewed, so this is defense in depth, but registry entries are meant to come in through contributor PRs.
Suggested approach
Use one helper for all region replacement, always pattern.sub(lambda _m: replacement, ...).
Escape <, > and & in embedded JSON as \u003c, \u003e and \u0026 (or at minimum </ and <!--).
Cover both cases in the new unit tests (see the test coverage issue).
Done when
A registry description containing backslashes or markup round-trips through sync_from_registry.py, and --check stays idempotent.
Activity