fix: preserve HTML entities in file content and commands #10805
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related GitHub Issue
Closes: #10804
Description
This PR removes the unescapeHtmlEntities function calls from all tool files that write content to files or execute commands. The function was converting HTML entities like ', <, >, &, and " to their character equivalents, which broke HTML, JSX, and TSX files that needed to contain actual HTML entities.
Key changes:
This implementation follows the patch provided by @Lissanro in the issue comments, with the additional improvement of adding tests that verify HTML entities are preserved rather than just removing old tests.
Test Procedure
Pre-Submission Checklist
Documentation Updates
Additional Notes
This is an attempt to address Issue #10804. Feedback and guidance are welcome.
The fix ensures that all models (including open-weight models like K2 Thinking) can properly write HTML entities to files without corruption. The previous behavior was causing syntax errors and agentic loop failures when models tried to write actual HTML entities.
Important
Remove
unescapeHtmlEntitiesto preserve HTML entities in file content and commands, updating tests accordingly.unescapeHtmlEntitiesfromWriteToFileTool.ts,ApplyDiffTool.ts,ExecuteCommandTool.ts, andMultiApplyDiffTool.tsto preserve HTML entities in file content and commands.writeToFileTool.spec.tsandexecuteCommandTool.spec.tsto verify HTML entities are preserved.executeCommandTimeout.integration.spec.ts.writeToFileTool.spec.tsandexecuteCommandTool.spec.tsto ensure HTML entities are not converted.unescapeHtmlEntitiesimport from affected files.This description was created by
for 3ec4371. You can customize this summary. It will automatically update as commits are pushed.