fix(printer): preserve JSON and HTML response content - #40
rupayon123 wants to merge 10 commits into
Conversation
|
Additional fixes pushed to this branch:
Full Go tests, go vet and build pass. Regressions verify PUBLIC/SYSTEM doctype identifiers and prevent document wrappers from being inferred from comments, script text or html-prefixed custom tags. Today's changes have no new findings under golangci-lint v2.13.2 using a migrated copy of the repository configuration. This is a scoped lint result: a full CLI-branch scan still reports 93 findings outside today's changes; the legacy v1 linter cannot read the installed Go 1.27 export format. Prepared with AI assistance. Changes are submitted for review; this is not a claim of maintainer approval. |
|
September 16 verified update: XML media types now render as text. Three regressions failed before the fix; the full Go suite, vet, build and scoped lint pass after it. Commits: Exact current head: AI-assisted with OpenAI Codex; changes and validation were inspected before submission. |
Problem and change
Preserve JSON and HTML response content during formatting. JSON keys and string values are escaped correctly, actual written byte counts include partial writes, and trailing documents/junk/read errors are reported rather than silently ignored. HTML formatting preserves script/style raw text, namespace-qualified attributes, and preformatted whitespace, including a leading newline.
Response selection now parses the media type itself: structured +json and XHTML bodies reach their formatters instead of being hidden as binary data, and a MIME parameter cannot accidentally select the JSON or HTML formatter.
Validation
Focused regressions reproduced every original failure. Full env -u NO_COLOR go test ./..., go vet ./..., builds, formatting and git diff --check pass. Regression cases include JSON round trips and failing writers/readers, HTML parse-format-parse content comparisons, namespaced attributes, and response media-type dispatch. Color environment isolation is submitted separately in PR39. golangci-lint was not run locally.
Prepared with AI assistance. Remote CI is verified separately on the latest head; passing checks do not imply maintainer approval.