Skip to content

fix(printer): preserve JSON and HTML response content - #40

Open
rupayon123 wants to merge 10 commits into
kavix:mainfrom
rupayon123:contribution/json-printer-correctness-20260913
Open

rupayon123 wants to merge 10 commits into
kavix:mainfrom
rupayon123:contribution/json-printer-correctness-20260913

Conversation

@rupayon123

@rupayon123 rupayon123 commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

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.

@rupayon123

Copy link
Copy Markdown
Contributor Author

Additional fixes pushed to this branch:

  • f996ae7: Preserve HTML doctype public and system identifiers.
  • c2ff913: Detect actual HTML document tags without mistaking comments, raw text or tag-name prefixes for wrappers.

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.

@rupayon123

Copy link
Copy Markdown
Contributor Author

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: a6438eb89b1789335ee4fb28b30ae61f103bc44a.

Exact current head: a6438eb89b1789335ee4fb28b30ae61f103bc44a. GitHub checks at this read: build: SUCCESS. Local results do not imply maintainer approval.

AI-assisted with OpenAI Codex; changes and validation were inspected before submission.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant