Skip to content

fix(cve-json): keep JSON escapes intact when replacing an embedded attachment - #1377

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:fix/generate-cve-json-splice-escapes
Sep 25, 2026
Merged

potiuk merged 1 commit into
apache:mainfrom
potiuk:fix/generate-cve-json-splice-escapes

Conversation

@potiuk

@potiuk potiuk commented Sep 24, 2026

Copy link
Copy Markdown
Member

Problem: Re-attaching CVE JSON to a tracker that already has an attachment
produced invalid embedded JSON whenever a string value contained escapes, for
example a multi-paragraph summary.

Root cause: _splice_attachment_into_body passed a string replacement to
re.sub. re.sub processes backslash escapes in a string replacement, so each
JSON \n became a real newline. Only the replace path was affected; the first
append does not use re.sub.

Fix: Pass a callable (lambda _: replacement) so the text is inserted verbatim.

Test: A new regression test covers \n, \\ and \1. It fails before the
fix and passes after; the full suite of 347 tests passes.

Impact: Any tracker re-attached with a summary containing escapes, typically a
multi-paragraph one, had invalid embedded JSON. Re-running the attachment after
this fix repairs it.

🤖 Generated with Claude Code

…tachment

_splice_attachment_into_body replaced an existing CVE-JSON block with
re.sub and a string replacement. re.sub processes backslash escapes in
a string replacement, so every JSON "\n" escape inside a string value
(for example a multi-paragraph summary) became a real newline and the
embedded JSON no longer parsed. Only the replace path was affected;
the first append does not go through re.sub.

Pass the replacement as a callable so it is inserted verbatim, and add
a regression test covering \n, \\ and \1 in the attachment JSON.

Generated-by: Claude Opus 5
@potiuk
potiuk merged commit d93fcb1 into apache:main Sep 25, 2026
9 checks passed
@potiuk potiuk added the contract:cve-authority Tool capability: CVE allocation / record management / publication label Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contract:cve-authority Tool capability: CVE allocation / record management / publication

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant