Skip to content

azd x - fix HTML-escaping of <, >, & in registry.json on publish#8498

Merged
JeffreyCA merged 4 commits into
mainfrom
copilot/fix-html-escaping-registry-json
Jun 3, 2026
Merged

azd x - fix HTML-escaping of <, >, & in registry.json on publish#8498
JeffreyCA merged 4 commits into
mainfrom
copilot/fix-html-escaping-registry-json

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 30, 2026

azd x publish rewrote literal <, >, and & in cli/azd/extensions/registry.json to \u003c, \u003e, \u0026 on every republish, producing noisy diffs in registry PRs. Root cause: json.MarshalIndent HTML-escapes by default with no opt-out.

Changes

  • internal/cmd/publish.gosaveRegistry now uses a json.Encoder with SetEscapeHTML(false), writing the three characters literally.
  • internal/helpers.go — Applied the same encoder to the empty-registry writer in CreateLocalRegistry for consistency.
  • internal/cmd/publish_test.go — Added a test asserting literal characters survive a round-trip and are not escaped.
func saveRegistry(path string, registry *extensions.Registry) error {
	var buf bytes.Buffer
	encoder := json.NewEncoder(&buf)
	encoder.SetEscapeHTML(false)
	encoder.SetIndent("", "  ")
	if err := encoder.Encode(registry); err != nil {
		return err
	}
	return os.WriteFile(path, buf.Bytes(), osutil.PermissionFile)
}

Output is identical to before except <, >, & are literal and Encoder.Encode appends a trailing newline (conventional for files).

Copilot AI linked an issue May 30, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix HTML-escaping of special characters in registry.json Fix HTML-escaping of <, >, & in registry.json on publish May 30, 2026
Copilot AI requested a review from JeffreyCA May 30, 2026 00:45
@JeffreyCA JeffreyCA marked this pull request as ready for review June 2, 2026 20:46
Copilot AI review requested due to automatic review settings June 2, 2026 20:46
Copilot AI and others added 3 commits June 2, 2026 20:47
Co-authored-by: JeffreyCA <9157833+JeffreyCA@users.noreply.github.com>
@JeffreyCA JeffreyCA force-pushed the copilot/fix-html-escaping-registry-json branch from b262a3e to add3e2c Compare June 2, 2026 20:48
@JeffreyCA JeffreyCA changed the title Fix HTML-escaping of <, >, & in registry.json on publish azd x - fix HTML-escaping of <, >, & in registry.json on publish Jun 2, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

📋 Milestone: June 2026

This work is tracked for June 2026. The team will review it soon!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the microsoft.azd.extensions developer kit publishing flow to avoid JSON HTML-escaping (<, >, &) when writing registry.json, preventing noisy diffs during republish and aligning local registry creation with the same behavior.

Changes:

  • Switch registry writing to json.Encoder with SetEscapeHTML(false) for both publish-time saves and local registry initialization.
  • Add a regression test to ensure <, >, and & remain literal (and that the file ends with a newline).
  • Bump the extension version to 0.11.1 and add a changelog entry.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
cli/azd/extensions/microsoft.azd.extensions/internal/cmd/publish.go Writes registry.json via json.Encoder with HTML escaping disabled.
cli/azd/extensions/microsoft.azd.extensions/internal/helpers.go Applies the same non-HTML-escaping JSON encoder to local registry creation.
cli/azd/extensions/microsoft.azd.extensions/internal/cmd/publish_test.go Adds a test to assert <, >, & are not escaped and output ends with a newline.
cli/azd/extensions/microsoft.azd.extensions/version.txt Bumps extension version to 0.11.1.
cli/azd/extensions/microsoft.azd.extensions/extension.yaml Updates the extension manifest version to 0.11.1.
cli/azd/extensions/microsoft.azd.extensions/CHANGELOG.md Adds a 0.11.1 changelog entry describing the fix.

Comment thread cli/azd/extensions/microsoft.azd.extensions/internal/helpers.go Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the ext-x microsoft.azd.extensions developer extension (azd x) label Jun 2, 2026
@JeffreyCA JeffreyCA merged commit f7ce733 into main Jun 3, 2026
22 checks passed
@JeffreyCA JeffreyCA deleted the copilot/fix-html-escaping-registry-json branch June 3, 2026 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ext-x microsoft.azd.extensions developer extension (azd x)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

azd x publish HTML-escapes <, >, & in registry.json on republish

4 participants