Skip to content

Conversation

bradchristensen
Copy link
Contributor

This PR fixes the JSX transformer incorrectly emitting HTML entities as-is (as plaintext) when they're supposed to be converted into the characters they encode (e.g. & should be replaced by &, ' should be replaced by ' and so on).

@Copilot Copilot AI review requested due to automatic review settings September 9, 2025 11:00
Copy link
Contributor

@Copilot 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 fixes HTML entity handling in the JSX transformer to correctly decode HTML entities into their corresponding characters instead of emitting them as plaintext. The fix ensures that entities like &, ", and · are properly converted to their actual characters (&, ", ·) during JSX transformation.

Key Changes

  • Updated regex group indices in the HTML entity replacer function to match the correct capture groups
  • Added null checks to prevent processing empty captures
  • Fixed entity decoding for decimal, hexadecimal, and named HTML entities

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/transformers/jsxtransforms/jsx.go Fixed regex group indices and added safety checks for HTML entity processing
testdata/baselines/reference/submodule/conformance/tsxReactEmitEntities.js Updated test baseline showing correct entity decoding (e.g., ··)
testdata/baselines/reference/submodule/conformance/tsxReactEmitEntities.js.diff Updated diff baseline reflecting the entity handling fix
testdata/baselines/reference/submodule/conformance/tsxReactEmitNesting.js Updated baseline showing &lt;x&gt; correctly decoded to <x>
testdata/baselines/reference/submodule/conformance/tsxReactEmitNesting.js.diff Updated diff baseline for the nesting test case

@bradchristensen
Copy link
Contributor Author

@microsoft-github-policy-service agree

@gabritto gabritto enabled auto-merge September 9, 2025 16:23
@gabritto gabritto added this pull request to the merge queue Sep 9, 2025
Merged via the queue into microsoft:main with commit 18a61f3 Sep 9, 2025
22 checks passed
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.

2 participants